jQWidgets Forums

jQuery UI Widgets Forums Grid Reset sortdatafield

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Kelvin 11 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Reset sortdatafield #47070

    Kelvin
    Participant

    Hi,

    Basically my aim is to allow user to do some kind of search and display the search result in the grid. The grid has been implemented with server side sorting and paging because the result return can be larged.

    Every search button click I managed to reset the grid using the below code before process binding the data to grid, but the removesort method did not clear the sortdatafield and it remembered the last sort data field and got passed as query string to the server. Is there anyway to force to either clear the sortdatafield or somehow use the default sort column that I have set in the sortcolumn and sortdirection properties?

    $(“#grid”).jqxGrid(‘clearselection’);
    $(“#grid”).jqxGrid(‘removesort’);
    $(“#grid”).jqxGrid(‘gotopage’, 0);

    Many thanks for your help

    Reset sortdatafield #47073

    Peter Stoev
    Keymaster

    Hi Kelvin,

    You may check the value of the “sortorder” parameter. It is null/undefined when the column’s sorting is removed. Alternatively, you may update the Grid’s parameters in the formatData callback of the jqxDataAdapter. Example: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-extra-http-variables.htm

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Reset sortdatafield #47080

    Kelvin
    Participant

    Hi,

    I have implemented by using the second suggested method like below, but somehow it make the call to the server twice. E.g. First I loaded the grid with data and sorted a field called ‘A’, then the next time when I fetch the data again from the server, it first make a call with sortdatafield set to A first then immediate make another call to the server with sortdatafield set to ‘DefaultSortFieldName’. How can I stop the first call?

    
    formatData: function (data) {
         if (init == true) {
               $.extend(data, {sortdatafield: "DefaultSortFieldName" });
               init = false;
         }
         return data;
    }
    

    If is not possible then I think it would be easier to implement the first suggestion by checking the ‘sortorder’ parameter in the server side. if is null, then force a default sort in the server.

    Many thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.