jQWidgets Forums

jQuery UI Widgets Forums Grid How to sort columns on other properties than datafield

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  omeslo 12 years, 3 months ago.

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

  • omeslo
    Participant

    I only just recently stumbled upon this beautiful suite of widgets and I’m diving into jqxGrid right now.
    One thing I cannot get my head around is the following:

    Imagine I have a column ‘Priority’ in my grid. It is fetched from the DB as (eg)
    id, name, sortorder
    1, High, 30
    2, Minor, 10
    3, Medium, 20

    I want this column to be sorted on the ‘sortorder’ value, while ‘name’ is the display value in the grid and the ‘id’ as the datafield.

    One obvious way would be to introduce a hidden column with the sortorders, and sort on that column when the ‘name’ header is clicked, but it appears it needs so much coding that there should be an easier way.

    I also looked at the custom sorting example. That might work, but it seems I have to write a custom function for each similar column and I have a few more of them.

    It would be appreciated if someone at least could point me in the right direction


    Peter Stoev
    Keymaster

    Hi omeslo,

    Each column which is displayed in the Grid should have a “datafield”. The “sortby” method expects 2 parameters – “datafield” and sort order(“asc”, “desc” or null). You may also pass the column’s displayfield to the “sortby” method.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    omeslo
    Participant

    Thank you for your quick reply.
    I figured that out. But I would like to keep the ‘id’ as datafield and ‘name’ as displayfield for further processing. Can I still sort on ‘sortorder’ in this case?

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

You must be logged in to reply to this topic.