1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    3
    Vote Rating
    0
    mrim is on a distinguished road

      0  

    Default Grid Sort for formatted date column in FF vs IE6

    Grid Sort for formatted date column in FF vs IE6


    It looks like the grid sorts by the data model's column value in IE6 and the view's rendered html in FF. Not certain about this. I'll have to investigate further but that's my initial assessment.

    As your RSS feed viewer, I parse the date on the way in (converting unix time values to javascript Date objects). I use the same renderer as in the RSS feed viewer. Many of my data rows have the same rendered date (i.e. same minute) but the Date object should be different by a couple seconds. In IE6, the sort is ordered correctly. In FF, it appears that all of the rows with the same rendered date are grouped together.

    setup code looks like:
    Code:
            function formatDate(dateVal){
                return (dateVal && dateVal.format) ? dateVal.dateFormat('M j, Y, g:i a') : 'Not Available';
            }
    
            var myColumns = [
                {header: "From", width: 128, sortable: true},
                {header: "Status", width: 45, sortable: true},
                {header: "Subject", width: 233, sortable: true},
                {header: "Date", width: 128, sortable: true, renderer: formatDate}
            ];
            var colModel = new YAHOO.ext.grid.DefaultColumnModel(myColumns); 
            function parseDate(noteUnixTime){
                return new Date(noteUnixTime*1000);
            }
    
            var schema = {
                tagName: 'note',
                id: 'id',
                fields: ['from', 'status', 'subject', 'date']
            };
            this.dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
            this.dataModel.addPreprocessor(3, parseDate); // add preprocessor to col 1 to parse dates
            this.dataModel.onLoad.subscribe(this.onLoad.createDelegate(this));
            this.dataModel.onLoadException.subscribe(this.showError.createDelegate(this));
            this.dataModel.setDefaultSort(colModel, 3, 'ASC');
    The library is awesome. I'm trying to evangelize to the rest of the crew at work by making some interesting examples.

    --Mark

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Just wondering, why did you post this as a bug? You will need to adjust your date parsing code. The Date sorting just calls date.getTime() and compares the the results. If the returned long is the same, they are considered equal.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    3
    Vote Rating
    0
    mrim is on a distinguished road

      0  

    Default


    Quote Originally Posted by jacksloc
    Just wondering, why did you post this as a bug? You will need to adjust your date parsing code. The Date sorting just calls date.getTime() and compares the the results. If the returned long is the same, they are considered equal.
    Yes, perhaps it belongs in a triage area. In the example I've got, the Date objects are different but yet they appear to be sorted correctly in IE6 and not in FF. That's why I reported it as a (potential) bug.

    I'll see if I can find a way to reproduce in a simpler example.

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Do you have it set to use date sorting?

    Try this small change (paste it in your file somewhere after yui-ext.js):

    Code:
    YAHOO.ext.grid.DefaultColumnModel.sortTypes.asDate = function(s) {
        if(s instanceof Date){
            return s.getTime();
        }
        return Date.parse(String(s));
    };
    The change return s.getTime(); instead of return s; will force FireFox to use the full time.

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    3
    Vote Rating
    0
    mrim is on a distinguished road

      0  

    Default


    No wasn't doing that.

    Do you have it set to use date sorting?
    Duh, I should've checked the docs on the top of the DefaultColumnModel. I used the default sort type. I'll try using sort.asDate. It'll probably work ...

    Sorry for the bogus bug report. This is probably a help query and not a bug report. Next time I'll post to the help section first.

  6. #6
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    I'll move it over there. Thanks.

Similar Threads

  1. Send sort column number in paged grid in Ext 1.0
    By JeffHowden in forum Community Discussion
    Replies: 3
    Last Post: 2 Jun 2008, 11:16 AM
  2. column sort makes ajax call for each time grid was recreated
    By lemontree in forum Ext 1.x: Help & Discussion
    Replies: 6
    Last Post: 4 Jul 2007, 2:14 AM
  3. Grid: Post column name (not just id) in remote sort
    By brondsem in forum Community Discussion
    Replies: 2
    Last Post: 18 Feb 2007, 4:01 PM
  4. Date string cannot be formatted
    By qiuyl in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 12 Dec 2006, 6:59 AM
  5. grid sort marks all rows by the first column
    By lsmith in forum Ext 1.x: Help & Discussion
    Replies: 8
    Last Post: 22 Nov 2006, 9:13 AM

Thread Participants: 1