Sunday, September 22, 2013

Re: DataGrid, updateRowData and setSelected

Hmm not sure, if I explained it correct in my above post. Another try.

My datagrid has some record in it. I press "prepareNewRecord"-Button, so i prepare for a new record. SelectionModel is cleared (no line should be selected now, see code below).
After the record is persisted successfuly, I retrieve the entity/Proxy from the server via find() and put it in my entityList of my AsyncDataProvider.
After that, i updateRowData and select the proxy in the selectionModel.

If there wasnt a line selected before, the new record gets inserted in the datagrid + it gets selected (yey!! just what I want). But if there was a line selected before i pressed "prepareNewRecord"-Button, it only inserts the new record in the datagrid, but sets the selection to the pre-"prepareNewRecord" line.

The problem seems to be caused by the onSelectionChangedHandler of the selectionModel.
After my Code from above worked, the onSelectionChanged Event is fired and in this event I dont get the item I had set programatically via selectionModel.getSelected().

And I dont understand why these lines dont cause a onSelectionChanged()-Event:
selectionModel.setSelected(currentRecord, false),
selectionModel.clear(),
selectionModel.getSelectedSet().clear(),
selectionModel.setSelected(null, true) doesnt cause a selectionChanged Event?

Any hint is appreciated.

Regards,
Manuel

Am Sonntag, 22. September 2013 19:39:51 UTC+2 schrieb Manuel:
Hi everyone,

I got a DataGrid with a AsyncDataProvider.
First I add a Record to my ListOfEntities via ListOfEntities.add(myNewEntity).
Then I set selected via Model.setselected(myNewEntity,true).
Then I call provider.updateRowData(Start, ListOfEntities);

Now my DataGrid shows the List including myNewEntity, but the selected Item in the List is not updated.

In general, the setSelection works. But when I also use updateRowData() the selected row is not correctly set. It stays unchanged.

How can i solve this?

Thanks in advanced.

Regards,
Manuel

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment