[英]GWT CellTable: Selecting one checkbox selects every checkbox/row in the table
I have a very basic CellTable in GWT right now and use a majority of the code shown here . 我现在在GWT中有一个非常基本的CellTable,并使用此处显示的大部分代码。
However when I toggle a checkbox, every single row gets highlighted. 但是,当我切换一个复选框时,每一行都会突出显示。
I did try so far: 我到目前为止尝试过:
Multi-/SingleSelectionMode: (I only want to get one row, so I would prefer SingleSelectionMode) Multi- / SingleSelectionMode :(我只想获得一行,所以我更喜欢SingleSelectionMode)
CheckBoxCell(true, true): -> This is exactly how I want the CellTable to look, however with these parameters I can't get an object with "getSelectedObject()". CheckBoxCell(true,true): - >这正是我希望CellTable看起来的样子,但是使用这些参数我无法获得带有“getSelectedObject()”的对象。 Other variations of the parameters(false,false/true, false) also didn't seem to work
参数的其他变体(假,假/真,假)似乎也不起作用
CellTable<Article> ArticleCt = new CellTable<Article>(KEY_PROVIDER);
ListHandler<Article> sortHandler = new ListHandler<Article>(Articles);
ArticleCt.addColumnSortHandler(sortHandler);
final MultiSelectionModel<Article> selectionModel1 = new MultiSelectionModel<Article>(KEY_PROVIDER);
ArticleCt.setSelectionModel(selectionModel1, DefaultSelectionEventManager.<Article> createCheckboxManager());
Column<Article, Boolean> checkColumn = new Column<Article, Boolean>(
new CheckboxCell(true, false)) {
public Boolean getValue(Article object) {
return selectionModel1.isSelected(object);
}
};
I want to have only the row with the checked checkbox selected so I can fetch the peticular row/object with selectionMode.getSelectedObject()
or selectionMode.getSelectedSet()
. 我想只选中选中了复选框的行,这样我就可以使用
selectionMode.getSelectedObject()
或selectionMode.getSelectedSet()
获取peticular行/对象。
However every single row gets highlighted. 但是每一行都会突出显示。
Your key provider, KEY_PROVIDER
in the question above, must provide unique and consistent keys per row. 上述问题中的密钥提供程序
KEY_PROVIDER
必须每行提供唯一且一致的密钥。 For example, each row might have an "ID" field. 例如,每行可能有一个“ID”字段。
If more than one row shares a key, then selecting one seems to be the same to the selection model as selecting both. 如果多个行共享一个键,那么选择一个键似乎与选择模型相同。 If a row's key is not consistent, then when a row is selected, it can't be queried later since its key changed.
如果行的键不一致,那么当选择某行时,由于其键已更改,因此无法在以后查询该行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.