Showing posts with label editorgrid. Show all posts
Showing posts with label editorgrid. Show all posts

Tuesday, July 20, 2010

Editor Grid and checkboxSelectionModel

I experienced that the check box selection model and the editor grid does not go along well if we are clicking on the row rather than only the check box. The problem is that the row gets selected and deselected when the editable cells are changed.

I needed to enable the select only when we click the first 2 columns and just editable on the rest.

A solution is to override handleMouseDown

  1: @Override
  2: protected void handleMouseDown(GridEvent e) {
  3: 	if (checkBoxOnly || checkBoxSynchronized) {
  4:         	if (e.getColIndex() < 3 && e.getEvent().getButton() == NativeEvent.BUTTON_LEFT) { 
  6: 	        	M m = listStore.getAt(e.getRowIndex());
  7: 			if (m != null) {
  8: 		        	if (isSelected(m)) {
  9: 					doDeselect(Arrays.asList(m), false);
 10: 				} else {
 11: 					doSelect(Arrays.asList(m), true, false);
 12: 				}
 13: 			}
 14: 		}
 15: 	} else {
 16: 	       super.handleMouseDown(e);
 17: 	}
 18: }

Wednesday, May 6, 2009

EditorGrid tab order in gxt

I had problems with editor grid previously too. But yesterday was heights. The tab order for the editorGrid was working fine if the grid store has previous values within it. My requirement is to add a new row if that is the last one and continue the tab order after that row into the next one. 

I tried adding the row using the BeforeEdit event for the Editor Grid and looking for that column. It so happens that the selection is lost for that cell, as soon as the row is added and tabs does not work after that.

So 

  1: GridModelData batchData = new GridModelData();
  2: grid.getStore().insert(batchData, i);
  3: ((CellSelectionModel<GridModelData>)grid.getSelectionModel()).selectCell(i - 1,"last column number");
We basically set the focus back to the last cell which was lost when we insert a row into the grid.