PDA

View Full Version : Select Items From Grid



dadasaheb_7
13 Jun 2010, 11:40 PM
I have a Problem with Selecting Items from the Grid (GXT 2.1.1), because some Items are without (IDs).
I have created a Grid<PerimeterModel> and store<PerimeterModel> in which PerimeterModel consists of (id, name)

Now I fetch some records of Perimetermodel from database which consists of perimeterIds and put it in store and do
resultGrid.getSelectionModel().selectAll(); which works fine.

Now I add list of PerimeterModels into the store :

List<PerimeterModel> list = new ArrayList<PerimeterModel>(0);

PerimeterModel perimeterModel1 = new PerimeterModel();
perimeterModel1.setName("Perimeter1");
list.add(perimeterModel1);

PerimeterModel perimeterModel2 = new PerimeterModel();
perimeterModel2.setName("Perimeter2");
list.add(perimeterModel2);

and then I do
store.add(list);
resultGrid.getSelectionModel().selectAll();

This only selects perimeterModel1 because both perimeterModel1 and perimeterModel2 have ids set to 0.
Implementation of GXT grid selection is I guess on Model ID, correct me if I am wrong.

Can this be made configurable or changed to something else?
Because the thing is I need to save the model from GUI in DB and new model will never have any ID since ID will be generated after storing that record in DB.

Please could you please comment on the same?

sven
14 Jun 2010, 1:06 AM
This only selects perimeterModel1 because both perimeterModel1 and perimeterModel2 have ids set to 0.
Implementation of GXT grid selection is I guess on Model ID, correct me if I am wrong.

Does perimeterModel1.equals(perimeterModel2) return true?

dadasaheb_7
14 Jun 2010, 1:15 AM
Thanks for your reply sven,
Yes I did Override the equals method by comparing ID and then by name, then it allowed me to check the models in store, but now it prevents me from manually deselecting those new models without ID from GRID, and also the header to select, deselect all has stopped working.

dadasaheb_7
16 Jun 2010, 1:57 AM
Any updates on the same, why the checkbox makes group of those models without ID were added?

sven
16 Jun 2010, 1:57 AM
You will need to give us a testcase that implements EntryPoint and shows your problem

dadasaheb_7
16 Jun 2010, 9:15 PM
The problem got solved, I did override the equals method properly and it worked.