Flexgrid Auto ReSort on Cell's ValueChange Event

Posted by: mmurugesan on 26 March 2019, 1:46 pm EST

    • Post Options:
    • Link

    Posted 26 March 2019, 1:46 pm EST

    Hi

    My grid is sorted in Ascending order by default and allows the user to change vice-versa. All my fields are editable and those are different types of fields like Text, Numeric, Date & Drop-down type fields. I applies cssClass based on the type.

    My requirement is, when the user change the cell’s value it should resort accordingly based on the new value. The scroll position should be at the same place where it was before changing the value.

    Much appreciate any suggestions/ideas.

  • Posted 27 March 2019, 3:32 am EST

    Flexgrid implements the required behavior by default. When you edit a cell, the grid gets sorted automatically if sorting is applied on the column. The grid also remains in the same position as it was before editing the cell.

    You can refer to the demo given below:

    https://demos.wijmo.com/5/PureJS/LearnWijmo/LearnWijmo/#pu062h9t

  • Posted 27 March 2019, 2:20 pm EST

    Thanks abhishek for your response. Here is my issue while doing the sorting.

    I’ve applied custom formats like if Country == “Italy” then row.isReadOnly = true. This is working fine while the grid loads first time and works fine while I click on the header for sorting. But when I change the cell’s value, the sorting working fine but the formats are gone. The row is becoming editable.

    Please note that this is happening only when the new value making the row re-positioning. For Example: Below is sample grid.

    ID Country

    1 USA

    2 UK

    4 Canada

    5 Italy

    If I change the ID from 2 to 3, the formats are applying as usual. Because still the UK country position is second. But if I change the ID from 2 to 6 then UK is moving to last row and this time the row.isReadOnly not applying for any of the rows.

    I’m not sure that whether I need to call the Row Format Logic Function in some specific place to keep the custom formats.

    Please share your suggestion to keep the custom formats. Thank you.

  • Posted 28 March 2019, 5:00 am EST

    Hi,

    In this case, we need to handle the loadedRows event and update the read-only state of the rows. Please refer to the sample given below. In this demo, all the rows with country “Germany” are read-only.

    https://jsfiddle.net/ashwin2409/rdwkv7m2/

    ~Sharad

  • Posted 28 March 2019, 12:19 pm EST

    Great… This worked for me. Now my code is like this:-

    this.flexGrid.loadedRows.addHandler(this.applyRowStyle.bind(this));

    Thank you Sharad for your response.

Need extra support?

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

Learn More

Forum Channels