*/
private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<String, CustomGridColumn>();
- private AbstractRowHandleSelectionModel<JsonObject> selectionModel = createSelectionModel(SharedSelectionMode.NONE);
+ private AbstractRowHandleSelectionModel<JsonObject> selectionModel;
private Set<String> selectedKeys = new LinkedHashSet<String>();
private List<String> columnOrder = new ArrayList<String>();
}
});
- getWidget().setSelectionModel(selectionModel);
-
getWidget().addSelectionHandler(internalSelectionChangeHandler);
getWidget().addSortHandler(new SortHandler<JsonObject>() {
}
AbstractRowHandleSelectionModel<JsonObject> model = createSelectionModel(mode);
- if (!model.getClass().equals(selectionModel.getClass())) {
+ if (selectionModel == null
+ || !model.getClass().equals(selectionModel.getClass())) {
selectionModel = model;
getWidget().setSelectionModel(model);
selectedKeys.clear();
editor.setGrid(this);
- setSelectionMode(SelectionMode.MULTI);
+ setSelectionMode(SelectionMode.SINGLE);
escalator.addScrollHandler(new ScrollHandler() {
@Override
* Grid initial setup
*/
private void initGrid() {
- setSelectionMode(SelectionMode.MULTI);
+ setSelectionMode(SelectionMode.SINGLE);
addSelectionListener(new SelectionListener() {
@Override
public void select(SelectionEvent event) {
}
@Test
- public void defaultSelectionModeIsMulti() {
- assertTrue(grid.getSelectionModel() instanceof SelectionModel.Multi);
+ public void defaultSelectionModeIsSingle() {
+ assertTrue(grid.getSelectionModel() instanceof SelectionModel.Single);
}
@Test(expected = IllegalStateException.class)
openTestURL();
GridElement gridAdd = $(GridElement.class).first();
- if (!gridAdd.isElementPresent(By.vaadin("#cell[9][1]"))
- || gridAdd.isElementPresent(By.vaadin("#cell[10][1]"))) {
+ if (!gridAdd.isElementPresent(By.vaadin("#cell[9][0]"))
+ || gridAdd.isElementPresent(By.vaadin("#cell[10][0]"))) {
Assert.fail("Grid with added data contained incorrect rows");
}
GridElement gridRemove = $(GridElement.class).get(1);
- if (!gridRemove.isElementPresent(By.vaadin("#cell[4][1]"))
- || gridRemove.isElementPresent(By.vaadin("#cell[5][1]"))) {
+ if (!gridRemove.isElementPresent(By.vaadin("#cell[4][0]"))
+ || gridRemove.isElementPresent(By.vaadin("#cell[5][0]"))) {
Assert.fail("Grid with removed data contained incorrect rows");
}
}
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
public class GridAddRow extends AbstractTestUI {
protected void setup(VaadinRequest request) {
final Grid grid = new Grid();
+ grid.setSelectionMode(SelectionMode.MULTI);
grid.addColumn("firstName");
grid.addColumn("age", Integer.class);
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.renderer.NumberRenderer;
public class GridColspans extends AbstractTestUI {
grid = new Grid(dataSource);
grid.setWidth("600px");
grid.getColumn("zipCode").setRenderer(new NumberRenderer());
+ grid.setSelectionMode(SelectionMode.MULTI);
addComponent(grid);
HeaderRow row = grid.prependHeaderRow();
openTestURL();
GridElement grid = $(GridElement.class).first();
assertEquals("Miles header wasn't present.", "miles", grid
- .getHeaderCell(0, 3).getText().toLowerCase());
+ .getHeaderCell(0, 2).getText().toLowerCase());
}
@Test
GridElement grid = $(GridElement.class).first();
// Overwritten foo property should not be sortable
- GridCellElement fooHeader = grid.getHeaderCell(0, 1);
+ GridCellElement fooHeader = grid.getHeaderCell(0, 0);
fooHeader.click();
assertFalse("Column foo was unexpectedly sorted.", fooHeader
.getAttribute("class").contains("sort"));
// Generated property miles is not sortable
- GridCellElement milesHeader = grid.getHeaderCell(0, 3);
+ GridCellElement milesHeader = grid.getHeaderCell(0, 2);
milesHeader.click();
assertFalse("Column miles was unexpectedly sorted.", milesHeader
.getAttribute("class").contains("sort"));
GridElement grid = $(GridElement.class).first();
// Generated property baz is sortable
- GridCellElement bazHeader = grid.getHeaderCell(0, 4);
+ GridCellElement bazHeader = grid.getHeaderCell(0, 3);
bazHeader.click();
assertTrue("Column baz was not sorted ascending", bazHeader
.getAttribute("class").contains("sort-asc"));
import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderCell;
import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.Grid.SelectionMode;
@Theme("valo")
public class GridHeaderStyleNames extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
Grid grid = new Grid();
+ grid.setSelectionMode(SelectionMode.MULTI);
grid.setContainerDataSource(BeanItemContainerGenerator
.createContainer(100));