ソースを参照

Fixes #1981 (some selections lost when scrolling)

svn changeset:5187/svn branch:trunk
tags/6.7.0.beta1
Marc Englund 16年前
コミット
cee7be72ce
1個のファイルの変更21行の追加9行の削除
  1. 21
    9
      src/com/itmill/toolkit/ui/Table.java

+ 21
- 9
src/com/itmill/toolkit/ui/Table.java ファイルの表示

@@ -1751,14 +1751,26 @@ public class Table extends AbstractSelect implements Action.Container,
}

// selection support
String[] selectedKeys;
LinkedList selectedKeys = new LinkedList();
if (isMultiSelect()) {
selectedKeys = new String[((Set) getValue()).size()];
// only paint selections that are currently visible in the client
HashSet sel = new HashSet((Set) getValue());
Collection vids = getVisibleItemIds();
for (Iterator it = vids.iterator(); it.hasNext();) {
Object id = it.next();
if (sel.contains(id)) {
selectedKeys.add(itemIdMapper.key(id));
}
}
} else {
selectedKeys = new String[(getValue() == null
&& getNullSelectionItemId() == null ? 0 : 1)];
Object value = getValue();
if (value == null) {
value = getNullSelectionItemId();
}
if (value != null) {
selectedKeys.add(itemIdMapper.key(value));
}
}
int keyIndex = 0;

// Table attributes
if (isSelectable()) {
@@ -1854,9 +1866,8 @@ public class Table extends AbstractSelect implements Action.Container,
target.addAttribute("key", Integer.parseInt(cells[CELL_KEY][i]
.toString()));
if (actionHandlers != null || isSelectable()) {
if (isSelected(itemId) && keyIndex < selectedKeys.length) {
if (isSelected(itemId)) {
target.addAttribute("selected", true);
selectedKeys[keyIndex++] = (String) cells[CELL_KEY][i];
}
}

@@ -1927,8 +1938,9 @@ public class Table extends AbstractSelect implements Action.Container,
target.endTag("rows");

// The select variable is only enabled if selectable
if (selectable) {
target.addVariable(this, "selected", selectedKeys);
if (selectable && selectedKeys.size() > 0) {
target.addVariable(this, "selected", (String[]) selectedKeys
.toArray(new String[selectedKeys.size()]));
}

// The cursors are only shown on pageable table

読み込み中…
キャンセル
保存