Event to handle sort

Posted by: chandrasekar_keerthana on 30 October 2019, 3:24 am EST

  • Posted 30 October 2019, 3:24 am EST

    Hi Team,

    We are facing issues with the Wijmo’s custom sort after we insert a row into the flexhseet’s itemsource. So we’re planning to implement custom sort in our application. I’m able to invoke the filterChanged handle while the asc/desc buttons are clicked. Please let me know if there’s a way to validate which button is clicked inside the filter pop up.

    Thanks,

    Keerthana

  • Posted 31 October 2019, 2:22 am EST

    Hi,

    If you wish to your own custom sort, I would suggest you use the sortComparer property of the CollectionView class. Please refer to the sample below demonstrating the same:

    https://stackblitz.com/edit/js-khmswq

    In this sample, if you will sort the country column, the data will be sorted according to the 2nd character instead of the first.

    Regards,

    Ashwin

    API Reference:

  • Posted 31 October 2019, 4:25 am EST

    Hi,

    Sorting the data according to the 2nd character instead of the first, is not the expected behaviour for our application.

    I’m unable to access the sort button element with the following code.

    var AscBtn = document.querySelector(‘button [wj-part=“btn-asc”]’);

    var sortBtns =document.querySelector(“[wj-part=‘div-sort’]”);

    It seems to return null. Can you please help me with it.

    Thanks.

  • Posted 31 October 2019, 11:48 pm EST

    Hi,

    You will need to call the querySelector method in the setTimeout method. Please refer to the link below for a demonstration:

    https://stackblitz.com/edit/js-v4xpmw

    ~regards

  • Posted 1 November 2019, 8:40 am EST

    Hi,

    Thanks Ashwin, it works.

    The issue with sort that we see is:

    We use observable array as datasource for flexsheet which is initialised with 3 custom rows on load. Sort icons from the filter panel is what we use. Sort works fine with these 3 records. But on adding a new row, and then sorting, the newly added rows disappear in the UI. After we insert a new row again, the earlier added rows also appear. Below is the code in place for insert row:

    active_sheet.beginUpdate();

    active_sheet.itemsSource.beginUpdate();

    active_sheet.insertRows(selectedRow, ROWCOUNT);

    while (ROWCOUNT > 0) {

            newrow = new CustomRecord(vm);
            newrow.YEAR = vm.get('ddYearPicker');
            newrow.VALIDATION_MESSAGE = DIRTY_RECORD_MARKER;
            active_sheet.sheets[0].itemsSource.splice(selectedRow + i - 1, 1, newrow);
            ROWCOUNT--;
            i++;
        }
    

    active_sheet.itemsSource.endUpdate();

    active_sheet.endUpdate();

    me.formatSheet(active_sheet);

    We had also tried the below code provided by your team earlier, which also didn’t work:

    active_sheet.insertRows(selectedRow, ROWCOUNT);

    while (ROWCOUNT > 0) {

    let row = active_sheet.rows[selectedRow + i];

    newrow = new CustomRecord(vm);

    //newrow.YEAR = vm.get(‘ddYearPicker’);

    newrow.VALIDATION_MESSAGE = DIRTY_RECORD_MARKER;

    $.extend(row.dataItem, newrow);

    ROWCOUNT–;

    i++;

    }

    Please suggest if there’s any other workaround that I can try out.

    Thanks,

    Keerthana

  • Posted 4 November 2019, 8:30 am EST

    Hi Keerthana,

    The cause of the issue may be that the new row is not being added to the data source properly. Could you please provide a sample replicating the issue so that we can assist you further?

    ~regards

  • Posted 6 November 2019, 7:40 am EST

    Hi Ashwin,

    Please checkout the sample code in the below path:

    https://codesandbox.io/s/tender-matsumoto-flt4x

    After adding a new row, try to sort ascending. And then move the cursor back to the top row and try to add a new row again. Now try to sort the records in descending, the newly added row disappears.

    please try it out and let me know if there’s any fix for it.

    Thanks,

    Keerthana

  • Posted 7 November 2019, 1:24 am EST

    Hi Keerthana,

    There must be an issue in the wijmo version you were using because it works as expected in the latest version.

    https://codesandbox.io/s/frosty-frog-fkuku

    Could you please upgrade your application to use the latest version of wijmo?

    Let us know if you face any issues while upgrading.

    ~regards

  • Posted 7 November 2019, 2:18 am EST

    Hi Ashwin,

    Every time we integrate with a new Wijmo version, we’re facing new issues. This is the reason why we stopped integrating newer versions. So, please check and let me know if the issues we raised earlier in the below links are addressed in the latest version.

    Internal tracking Id: 365642

    https://www.grapecity.com/forums/wijmo/insert-row-in-flexsheet---

    Internal tracking Id : 366431.

    https://www.grapecity.com/forums/wijmo/flexgrid-not-displaying-te

    Internal tracking ID: 354953

    https://www.grapecity.com/forums/wijmo/assertion-failed-in-wijmo-_2

    Internal tracking Id: 365643

    https://www.grapecity.com/forums/wijmo/flexsheet-insert-row-after

    Thanks,

    Keerthana

  • Posted 7 November 2019, 11:45 pm EST

    Hi Keerthana,

    We are sorry for the inconvenience caused. There are some versions that have breaking changes and may break the application.

    The bugs 354953 and 366431 are fixed in the latest versions. For the remaining bugs, we have asked the dev team to provide an ETA.

    ~regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels