View Full Version : Hide Records in Grid

21 Mar 2011, 8:44 AM
I have a group of grids that contain records which the user can add, edit and delete. When the user tries to delete a record, what we're trying to do is flag the record as deleted. We want to keep the row for our records but we don't want the user to see it anymore. When the user is done with his modifications we batch all the grid records to the server.
The problem I'm having is how do I hide the record in the table until we're ready to save it? I've tried filtering on the liststore but it seems when I filter out the removed records they don't get returned to the server on save. The liststore basically shrinks everytime I filter out another record.

Basically what I'm trying to do is I want to flag the record's attribute, hide it from the user, and then send the entire collection to the server as normal. Can anyone help me?

21 Mar 2011, 1:51 PM
I take it you are not using a reverse-MVP strategy? ie. you are bootstrapping your grid directly from the server in a store? The reason why I ask, is in reverse-MVP you are only displaying what is of relevance but the "model" (ie. the bean list that represents persisted data) is in your presenter outside of the view (ie. GXT) framework. In that type of example removing the row from the grid (and thus underlying data store) could simply toggle a value in the underlying persisted data indicating it is deleted.

Another option... you can listen for the remove event from the store. If the row never needs to be shown to the user in that session again, you could simply capture the removed rows as ModelData's and store these in your page and post these "with" your updates (as the deletion list). Likely in the case of delete all you need is the IDs or something anyhow (rather than the entire record). You don't state how you are managing your updates to the server. If it was a server posting you could simply tack on another parameter for "deletedItems" or if it was RPC you could add another method parameter for the deleted items.