FlexGrid Row Update

Posted by: sharmaspk-1984 on 14 September 2017, 11:11 am EST

    • Post Options:
    • Link

    Posted 14 September 2017, 11:11 am EST

    Dear,

    I am implementing a project, in which I have to reload/refresh only one row of flexgrid on behalf of unique row id available in my datasource and this id is also visible in flexgrid. Is it possible, Please! provide a sample code with required explanations.

  • Posted 14 September 2017, 11:11 am EST

    Please explain in more detail.

    You want to load a single item from the server and change that in the grid’s data source? Or you have changed it in the data source and want the grid to refresh?

  • Posted 14 September 2017, 11:11 am EST

    I explain my need in detail, after that you will be able to give me proper solution. Actually, I have updated only one record in server, So I want to refresh that single row in flexgrid, I don’t want to reload whole flexgrid because if updated row is at page index greater than 1, Flexgrid will be reloaded and I have to reset that indexes. So, I don’t want to reload flexgrid, I only want to refresh that perticular row from server data.

  • Posted 14 September 2017, 11:11 am EST

    Sorry, still not detailed enough.

    The grid doesn’t know anything about the server. It only knows about the CollectionView that contains the data it is displaying. It will update the display when the CollectionView notifies.

    So this really is a question about CollectionView. Now the question is how is the CollectionView communicating with the server, and who is changing the data.

    If the change is made by your app, things are simple. For example, the user clicks a button that causes your code to make a change to the data. In this case, you can just call refresh on the CollectionView and that will be it:

    flex.collectionView.refresh();

    If the change happened on the server, then the first thing you need is some mechanism to detect the change. You can either poll the server or receive push messages (socket-style). Either way, when you know that data changed you could either reload the collection view (which it sounds like you don’t want to do) or you can get only the record that changed and update your collection view:

    function dataChanged(changedItem) {

    var list = flex.collectionView.sourceCollection;

    var index = lookUpItemByIndex(list, changedItem);

    if (index > -1) {

    list[index] = changedItem; // update the item

    flex.collectionView.refresh(); // refresh the view

    }

    }

    I hope this helps.

  • Posted 18 April 2018, 10:24 am EST

    Thanks Bernado, this is what I was looking for, I was updating my CollectionView the same way that is shown in your example, but I was calling refresh on my grid instead of on the CollectionView. Calling refresh on the CollectionView solved my issue.

    Thanks!

  • Posted 30 July 2019, 11:25 pm EST

    Thanks. That has helped me as well :slight_smile:

Need extra support?

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

Learn More

Forum Channels