jQuery UI Widgets Forums Grid Sorting based on Hidden Column

This topic contains 8 replies, has 2 voices, and was last updated by  pius.satpathy 11 years, 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • Sorting based on Hidden Column #18246

    I have a requiremnt to sort basd on a hidden column.

    For example I have a grid having column A and Column H(Hidden column).

    Coulumn A displays Name +Address and Coulmn H contains only names.

    When I wanted to apply sort on A, I would like to sort on the basis of Column H which contains only Name.I do not want to use custom sort and want to use the default sort provided by jqx grid.

    Sorting based on Hidden Column #18247

    Dimitar
    Participant

    Hello pius.satpathy,

    Each column’s sort menu applies sorting only to the column it belongs to. However, you may sort programmatically with the method sortby, i.e.:

    $('#jqxGrid').jqxGrid('sortby', 'columndatafield', 'asc');

    where columndatafield is the datafield of Column H.

    Best Regards,
    Dimitar

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

    Sorting based on Hidden Column #18251

    If I write above code inside the sort event handler then event handler would be called infinetly .

    For example I clicked on sort ascending on Column A then below code will be executed infinetly as $(‘#jqxGrid’).jqxGrid(‘sortby’, ‘H’, ‘asc’) will again raise an event ‘sort’ inside the code.

    $(‘#jqxGrid’).on(‘sort’,function(event) {

    $(‘#jqxGrid’).jqxGrid(‘sortby’, ‘H’, ‘asc’);

    })

    Regards,
    Pius

    Sorting based on Hidden Column #18252

    Dimitar
    Participant

    Hi Pius,

    That is to be expected. What I meant was to call the method on a click of a button, for example.

    Best Regards,
    Dimitar

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

    Sorting based on Hidden Column #18254

    Thanks

    We wanted to use the default menu items provided by jqx grid. How can I capture the click event when I click default “sort ascending” , “sort descending” and “Remove Sort” menu items of jqx grid ?

    OR

    Suppose the Grid is generated using A and Hidden coulmn (H). Now I wanted to click the header A so that sorrting logic will be applied on H and accordingly A should be rendered.How can achieve this?

    Pius

    Sorting based on Hidden Column #18258

    Dimitar
    Participant

    Hi Pius,

    Here is the solution for the latter case:

    $("#jqxGrid .jqx-grid-column-header").click(function () {
    $('#jqxGrid').jqxGrid('sortby', 'H', 'asc');
    });

    Best Regards,
    Dimitar

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

    Sorting based on Hidden Column #18386

    Hi Dimitar,

    Thanks for your help.

    Now I am able to sort based on hidden column.

    But Now the isue is that “sort ascending” , “sort descending” and “Remove Sort” menu items of jqx grid are not getting changed.

    For example when I click ” sort ascending” of column A .Sorting is done based on Hidden column H .But after sorting the menu item ” sort ascending” should be disabled and “sort descending” , “Remove Sort” should be enabled.But this is not happening.

    This might be due to the following reason:

    When the following statement is getting executed, menu items (sort ascending” , “sort descending” and “Remove Sort” ) of Hiddden column is affected not the column.

    $(‘#jqxGrid’).jqxGrid(‘sortby’, ‘H’, ‘asc’);

    Can you please help me on this?

    -Pius

    Sorting based on Hidden Column #18401

    Dimitar
    Participant

    Hi Pius,

    This is happening because you sort by the hidden column, and not by the visible column. Thus, there is no sort to remove from the visible column. Unfortunately, there is no workaround for this. However, you may still use Custom Sorting.

    Best Regards,
    Dimitar

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

    Sorting based on Hidden Column #19959

    Thank you Dimitar for all your help

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

You must be logged in to reply to this topic.