}
}
The unique key is the combination of ID and No columnso how to fix?
On Sunday, December 22, 2013 12:43:04 AM UTC+11, Donald Mteka wrote:And as a side note, your null check in ProvidesKey implementation is insignificant as the NullPointerException would have been already thrown at line:Hello Tom,your problem stems from the use of newly created array objects in your ProvidesKey and checkbox Column implementations. These array objects returned for getKey(..) and getValue(...) would never equal any other! Hence model.isSelected(..) will always return false.
RegardsString[] itemArr={item[0],item[1]};
On Sat, Dec 21, 2013 at 4:08 PM, Tom <Henr...@gmail.com> wrote:
Here is my problem. I have simple table with 3 columns (Id, no, text) Id and no combination creates a unique key for each row.
Id - no - text 12 - 1 - my text1 12 - 2 - my text2 13 - 1 - cool 13 - 2 - cool2 13 - 3 - cool3Now, i want to load these data into a CellTable with 4 columns (the 1st column is checkBoxColumn, the other 3 columns are ID/No/Text textcolum. I also want to put a SelectAllCheckBox on the Header of checkBoxColumn so that when user click on selectAllCheckBox then all the current visible checkBoxes got selected (of cause celltable could have many page but it will select only the visible ones).
Here is the code, i finished all the requirements except 1, that is "when i clicked the selectAllCheckBox, the
selectionModel
got selected but the correspondingly checkBoxes were not selected.Here is the Code.
public static final ProvidesKey<String[]> KEY_PROVIDER = new ProvidesKey<String[]>() { @Override public Object getKey(String[] item) { String[] itemArr={item[0],item[1]}; return item == null ? null : itemArr; } };
Here is the main CrllTable code:
final MultiSelectionModel<String[]> selectionModel = new MultiSelectionModel<String[]>(KEY_PROVIDER); final CellTable<String[]> cellTable = new CellTable<String[]>(); Column<String[], Boolean> checkColumn = new Column<String[], Boolean>( new CheckboxCell(true, false)) { @Override public Boolean getValue(String[] object) { // Get the value from the selection model. String[] objectArr={object[0],object[1]}; return selectionModel.isSelected(objectArr); } }; cellTable.setSelectionModel(selectionModel); CheckboxHeader selectAllCheckBoxHeader = new CheckboxHeader(); selectAllCheckBoxHeader.addValueChangeHandler(new ValueChangeHandler(){ @Override public void onValueChange(ValueChangeEvent event) { // TODO Auto-generated method stub System.out.println("test"); for (String[] item : cellTable.getVisibleItems()) { if (!selectionModel.isSelected(item)) { System.out.println(Arrays.toString(item)); selectionModel.setSelected(item, true); } } } }); cellTable.addColumn(checkColumn, selectAllCheckBoxHeader);
When I clikced the selectAll, then non of visible checkBoxes got check, but when printout
Set<String[]> selSet=selectionModel.getSelectedSet(); for(String[] s : selSet){ System.out.println("Mine: "+Arrays.toString(s)); }
it showed the currect selected items
Suppose pageSize is 3, then Output :
Mine: [12,1,my text1] Mine: [12,2,my text2] Mine: [13,1,cool]So how to make visible checkBoxes got selected automatically EXACTLY and CORESPONDINGLY /In TANDEM as the
selectionModel
got selectedNote: I also tried
cellTable.setSelectionModel(selectionModel, DefaultSelectionEventManager.<String[]> createCheckboxManager());
but not working.To post to this group, send email to google-we...@googlegroups.com.--
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.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
--
Donald Mteka
+255653105004
--
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.
--
Donald Mteka
+255653105004
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