Be sure your post includes:
Greetings,
We are using SmartGWT Power 2.4. I am not sure if anyone out there has done this yet but any tips would be appreciated.
I am trying to create embedded component within a List grid. That component has a ListGrid that I wish to set focus to a particular cell. I have searched the forums and came across the
method of the ListGrid class and thought that would provide my solution but it does not seem to to work.
Below is a simplified version of the code I am trying to get working. Essentially I setup a cell click handler on the grid and if a cell in a particular column was clicked I call a method that ultimately creates a grid adds that 2nd grid as the 1st's embeddedComponent. It all works beautifully except getting focus set in the first cell of the first row of the embedded grid. I have tried various enumerations of the
method but to no avail. Any thoughts would be greatly appreciated.
Greetings,
We are using SmartGWT Power 2.4. I am not sure if anyone out there has done this yet but any tips would be appreciated.
I am trying to create embedded component within a List grid. That component has a ListGrid that I wish to set focus to a particular cell. I have searched the forums and came across the
Code:
startEditing(rowNum, colNum, suppressFocus)
Below is a simplified version of the code I am trying to get working. Essentially I setup a cell click handler on the grid and if a cell in a particular column was clicked I call a method that ultimately creates a grid adds that 2nd grid as the 1st's embeddedComponent. It all works beautifully except getting focus set in the first cell of the first row of the embedded grid. I have tried various enumerations of the
Code:
startEditing()
Code:
//Set up the handler to expand and what not
listGrid.addCellClickHandler(new CellClickHandler() {
@Override
public void onCellClick(CellClickEvent event) {
record = event.getRecord();
int colNum = event.getColNum();
int rowNum = event.getRowNum();
ListGridField field = listGrid.getField(colNum);
String fieldName = listGrid.getFieldName(colNum);
String fieldTitle = field.getTitle();
if(fieldTitle.equalsIgnoreCase("Item")) {
createItemCellEmbeddedComponent(listGrid, rowNum);
}
}
});
private void createSKUCellEmbeddedComponent(final ListGrid listGrid, final int recordNum) {
//Get the data source
DataSource dataSource = RandomDataXMLDS.getInstance();
ListGridField rowNum = new ListGridField("itemNum", "ID");
rowNum.setWidth(65);
rowNum.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record,
int rowNum, int colNum) {
return rowNum +"";
}
});
ListGridField fooField = new ListGridField("foo", 100);
ListGridField barField = new ListGridField("bar", 100);
ListGridField foobarField = new ListGridField("foobar", 100);
ListGrid grid = new ListGrid();
grid.setWidth(300);
grid.setHeight100();
grid.setAutoFetchData(true);
grid.setDataSource(dataSource);
grid.setCanEdit(true);
grid.setAutoFitData(Autofit.HORIZONTAL);
grid.setFields(rowNum, fooField, barField, foobarField);
grid.startEditing(0,0,false);
VLayout vlayout = new VLayout();
vlayout.setShowEdges(true);
vlayout.setMembersMargin(5);
vlayout.setLayoutMargin(10);
vlayout.setWidth(300);
vlayout.setHeight(300);
vlayout.addMember(grid);
//This is where the magic happens, adding the Canvas/Layout/somethat that iherits from Canvas to the list Grid
listGrid.addEmbeddedComponent(vlayout, record);
}
Comment