jQWidgets Forums

jQuery UI Widgets Forums Grid Custom Sorting

This topic contains 5 replies, has 4 voices, and was last updated by  admin 4 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Custom Sorting #14825

    f310
    Member

    Hi, I have 2 questions about custom filters:

    1. Custom filter for 1 column.
    I need to write a custom comparator for just 1 column.
    Is there a way to implement a custom sort function for just one column… something like

    if(column == ) {
    … use custom comparater
    }
    else {
    … hook into existing compators for column type…
    }

    2. Multisort columns
    I am trying to figure out a way of sorting on multiple columns.
    For example If I sort by “name”, then sort by a date column. I want the date column to be in order but also ensure names are still sub sorted rather than displayed randomly when the dates are the same. (hope that made sense).
    Not sure if anyone has successfully implemented this using a custom sort function but I’m guessing I need a way of holding the state of the “previously sorted column”.

    Any ideas/tips/tricks?

    Many Thanks!

    Custom Sorting #14832

    Peter Stoev
    Keymaster

    Hi f310,

    1. For Custom sorting see: customsorting.htm.

    2. Multi Column Sorting is not available.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Custom Sorting #112622

    robf
    Participant

    Hello,

    When performing a multisort is there a way to show the number for the order of the sort?
    – e.g. grid with 4 columns A, B, C, D
    sort by col B, C, A would show headers with B(1), C(2), A(3)

    Currently user has no way to understand the primary order of sorts!

    Thanks.
    Rob

    Custom Sorting #112635

    admin
    Keymaster

    Hi Robf,

    1. Update of the post: Multi column sorting is available.

    2. We do not have a functionality in our Grid, which shows the multi-column sorting order.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Custom Sorting #112661

    robf
    Participant

    Any ideas how I might hook that in myself?
    ty

    Custom Sorting #112671

    admin
    Keymaster

    Hi robf,

    You can bind to the ‘sort’ event.

    $("#jqxGrid").on("sort", function (event) 
    {
        // event arguments.
        var args = event.args;
        // sorting information.
        var sortInfo = event.args.sortinformation;
        // sort direction.
        var sortdirection = sortInfo.sortdirection.ascending ? "ascending" : "descending";
        // column data field.
        var sortColumnDataField = sortInfo.sortcolumn;
    });  

    If you are using Angular, React or Vue you may look at the API Docs on our website for binding to events in these frameworks.

    Then my suggestion is to have an Array variable where you store the details about the sorting and update that variable each time the “sort” event is called. I suggest you using this event due to the reason that it is fired when the sorting in the Grid is changed, which may happen through API, click on the column header or from the column menu.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.