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.
-
Author
-
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.
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,
DimitarjQWidgets team
http://www.jqwidgets.com/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,
PiusHi Pius,
That is to be expected. What I meant was to call the method on a click of a button, for example.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/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
Hi Pius,
Here is the solution for the latter case:
$("#jqxGrid .jqx-grid-column-header").click(function () { $('#jqxGrid').jqxGrid('sortby', 'H', 'asc');});
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/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
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,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank you Dimitar for all your help
-
AuthorPosts
You must be logged in to reply to this topic.