Results 1 to 3 of 3

Thread: Sorting in grid on basis of two fields.

  1. #1

    Exclamation Sorting in grid on basis of two fields.

    I have a grid having two fields, newsdate and newstime, and use a single column to render both, now I want to sort this grid on basis of date and time both, where as currently ext js sorts it on basis of date only.


    var
    readerNewsLatest = new Ext.data.JsonReader( {
    root :
    'response.data.newslist.news'

    }, [
    {name :
    'cocode', type : 'string'},
    {name :
    'newsdate', type : 'string'},
    {name :
    'newstime', type : 'string'},
    {name :
    'heading', type : 'string'},
    {name :
    'captions', type : 'string'},
    {name :
    'arttext', type : 'string'}
    ]
    );

    var dtStartDate = new Date(new Date().valueOf()-(60*(24*60*60*1000)));
    var sStartDate = fNewsGetDDNumber(dtStartDate.getMonth()-1)+"-"+fNewsGetDDNumber(dtStartDate.getDate())+"-"+dtStartDate.getFullYear();
    var respLatestNews=ajaxFunction("GET",'${mktNewsMoreLatestResURL}&actionid='+pageActionIdNewsMoreLatest+'&fromdate='+sStartDate+'&recordcount='+globalRowCount,false);
    var jsonLatestNews=Ext.util.JSON.decode(respLatestNews);
    var storeLatest = new Ext.data.Store( {
    reader : readerNewsLatest,
    proxy:
    new Ext.ux.data.PagingMemoryProxy(jsonLatestNews),
    listeners : {
    'load' : function(store) {
    var iTotalCount=store.getTotalCount();
    },
    'exception' : function(dp, type, action) {
    this.removeAll();

    }}
    });
    var tbNewsLatestPaging = new Ext.PagingToolbar({
    store: storeLatest,
    pageSize:5,
    displayInfo:
    true,
    forceFit:
    true,
    doRefresh:
    function(){
    nCurrentCursorLatest =
    this.cursor;
    respLatestNews=ajaxFunction(
    "GET",'${mktNewsMoreLatestResURL}&actionid='+pageActionIdNewsMoreLatest+'&fromdate='+sStartDate+'&recordcount='+globalRowCount,false);
    jsonLatestNews=Ext.util.JSON.decode(respLatestNews);
    gridLatestNews.getStore().removeAll();
    gridLatestNews.getStore().proxy=
    new Ext.ux.data.PagingMemoryProxy(jsonLatestNews);
    gridLatestNews.getStore().load({params:{start:nCurrentCursorLatest, limit:5}});
    }
    });

    ?
    function rndNewsTime(value, meta, record, rowIndex, colIndex, store) {
    return String(record.get("newsdate")).substring(0,String(record.get("newsdate")).lastIndexOf("-")).replace(/-/g,' ')+", "+value;
    }
    function rndNewsURL(value, meta, record, rowIndex, colIndex, store) {
    return'<div><span style=\"cursor:pointer\">' + ((String(value).length>55)?(String(value).substring(0,55)+'...')value)) + '</span></div>';
    }
    function fGetSortedTime(value, meta, record, rowIndex, colIndex, store){
    var sDate = String(record.get("newsdate"));
    var sTime = String(record.get("newstime"));
    var testMonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    var dateMonth;
    for(i=0;i<12;i++){
    if(testMonth[i]==(sDate.substr(3,3))){
    dateMonth = i+1;
    }
    }
    var dateYear =sDate.substr(7,4);
    var dateDate = sDate.substr(0,2);
    var timeHOUR = sTime.substr(0,2);
    var timeMinute = sTime.substr(3,2);
    finalDate =
    new Date(dateYear,dateMonth-1,dateDate,timeHOUR,timeMinute,0);
    //alert(finalDate);

    return finalDate.getTime();
    };

    var cmNewsMoreLatest = new Ext.grid.ColumnModel( {
    columns : [ {
    width : 58,
    dataIndex :
    'newstime',

    multipleSortInfo: [{field:
    'newsdate', direction:'DESC'}, {field: 'newstime', direction:'DESC'}],
    sortable:
    true,
    renderer:rndNewsTime

    }, {
    width : 200,
    dataIndex :
    'heading',
    renderer: rndNewsURL
    }
    ]
    });



  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    1. It's multiSortInfo and not multipleSortInfo.
    2. multiSortInfo is a config option of the store and not of the columnmodel.

    ps. I recommend using PagingStore instead of PagingMemoryProxy.

  3. #3

    Default

    Is it necessary to use pagingStore instead of pagingmemoryProxy for sorting...???
    I used multistoreinfo in store but it is still niot working there..

    Can you suggest any way by which I can do that...

Similar Threads

  1. Populating rest of RowEditor fields on basis of first combobox field.
    By slashn10 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 4 Jan 2011, 12:11 PM
  2. Filter the Grid XML on the basis of values selected in ComboBoxes
    By John Mathew in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 11 Jun 2009, 11:48 AM
  3. this.fields is undefined in store.sort after sorting grid column
    By bradlymathews in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Mar 2009, 3:50 PM
  4. Display Different GXT Tooltip on a per cell basis in a Grid
    By sbarkdull in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 11 Dec 2008, 5:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •