No announcement yet.
  • Filter
  • Time
Clear All
new posts

    smartgwt listgrid search on cached data remove selected records

    Hi Team,

    I have a multiple selected list grid bounded by datasource and have search on each field.User select few record in the list grid and then search on grid and clear search filter afterword.
    Now my grid have all record unselected. Is there any way local cache of this listgrid can maintain the selected records.

    Parvesh Goyal

    before on entering search box, call getSelectedRecords() and store this, and afterwards, call selectRecords().

    Should work, shouldn’t it?

    Best regards


      It's not a good idea to try to maintain a selection of records that have been hidden by filtering. It means that if the end user takes some kind of action like deleting or moving all selected records, they are acting on records they can't see.


        Hi Team,

        The issue is with the listgrid local cache. List grid local cache does not have the selected item records in its cache so it remove it once filter cleared(As data then get rendered from local cache) .Is there any event which we can fire when data get rendered from local cache or is there any way we can update local cache.

        Parvesh Goyal


          Yes, as indicated above, that’s intentional. If you want to override this behavior, you could capture the selected records before filters are applied, or you could use an actual field of type:”Boolean” to store information if you intend it to be permanent.

          The set of selected records does not persist after filtering, by design.


            Hi Team,

            I have captured the user selected records in the list before applying filter.Now user apply a filter and later on clear that filter to get the complete data again in listGrid. In this case it render the list from the local cache. There is no way to capture event when list grid serve data from local cache. I need to update data for selected records when it get rendered from local cache.
            Last edited by preeti_kanyal; 30 Nov 2019, 02:25.


              To reiterate, having selected items that are hidden from the user is generally a bad UE.

              If you want to implement a bad UE, you are presumably calling some API to clear the filter criteria, so that's when you would re-select the records that you are trying to maintain as the selection.

              If you are referring to the end user clearing filter criteria by eg editing filter criteria in the filter editor, DataChanged fires as does filterEditorSubmit - remember, SmartGWT comes with documentation, so these things are easy to determine.


                I had the same issue when filtering. I solved it by using a Map to store the selected records with the record's primary key as the map key.
                Then, using addDataChangedHandler, I stream through the results and select the related records.
                This method solves the issue of only selecting records that are listed in the grid as well.

                grid.addDataChangedHandler(event ->
                grid.selectRecords( -> MAP.containsKey(listGridRecord.getAttributeAsLong(PRIMARY_KEY))).toArray(Record[]::new)));
                Hope this helps.