Hi,
I have found a problematic sequence of actions when enabling/disabling ListGridField's edit property. After a precise sequence, calling the setCanEdit(true or false) method on one (or many) fields becomes ineffective at changing the cell's edit property.
Here is a sample application I made to demonstrate the problem:
//1-The application starts will all cells not editable - i.e. setCanEdit(false)
//2-Toggle B cell edition (On) - The B field becomes editable
//3-Toggle B cell edition (Off) - The B field becomes non-editable
//4-Toggle A+MiddleCell edition (On) - The A and Middle cell will not become editable even with setCanEdit(true) called on their fields.
// The only way to get it back is to toggle the B cell edition again.
public class ListGridEnableDisable {
boolean isHandlerCellEditable = false;
boolean isBCellEditable = false;
ListGrid myGrid = new ListGrid();
ListGridField a1 = new ListGridField("A", "A1");
ListGridField middleField = new ListGridField("Middle", "Middle Cell");
ListGridField b1 = new ListGridField("B", "B1");
IButton toggleAMiddleButton = new IButton("Toggle A+Middle edit");
IButton toggleBButton = new IButton("Toggle B cell edit");
public void onModuleLoad() {
String var = "";
try {
var = DOM.getInnerHTML(DOM.getElementById("listgrid_test "));
} catch (Throwable e) {
var = "";
}
if(!var.equalsIgnoreCase("listgrid_test_entrypoint "))
return;
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
toggleAMiddleButton.setWidth(200);
toggleAMiddleButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
a1.setCanEdit(!isHandlerCellEditable);
middleField.setCanEdit(!isHandlerCellEditable);
isHandlerCellEditable = !isHandlerCellEditable;
}
});
toggleBButton.setWidth(200);
toggleBButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
b1.setCanEdit(!isBCellEditable);
isBCellEditable = !isBCellEditable;
}
});
myGrid.setFields(a1, middleField, b1);
myGrid.setWidth100();
myGrid.setHeight100();
myGrid.setCanEdit(true);
a1.setCanEdit(false);
middleField.setCanEdit(false);
b1.setCanEdit(false);
createContent();
layout.addMembers(myGrid, toggleAMiddleButton, toggleBButton);
RootPanel.get().add(layout);
}
private void createContent()
{
//Add records
ListGridRecord myRecords[] = new ListGridRecord[3];
myRecords[0] = new ListGridRecord();
myRecords[0].setAttribute("A", "r1 data");
myRecords[0].setAttribute("B", "r1 data");
myRecords[1] = new ListGridRecord();
myRecords[1].setAttribute("A", "r2 data");
myRecords[1].setAttribute("B", "r2 data");
myRecords[2] = new ListGridRecord();
myRecords[2].setAttribute("A", "r3 data");
myRecords[2].setAttribute("B", "r3 data");
myGrid.setData(myRecords);
}
}
I have placed a breakpoint in the toggle handler before executing step #4 described above, and I see that setCanEdit(true) is called on both A and Middle cells, however, trying to edit the cells afterwards is not possible.
I am using smartGWT 3.1 and I also tried the latest 4.0 recently and I have the same behavior. I am using Firefox and Chrome and both have the same behavior.
Thank you
I have found a problematic sequence of actions when enabling/disabling ListGridField's edit property. After a precise sequence, calling the setCanEdit(true or false) method on one (or many) fields becomes ineffective at changing the cell's edit property.
Here is a sample application I made to demonstrate the problem:
//1-The application starts will all cells not editable - i.e. setCanEdit(false)
//2-Toggle B cell edition (On) - The B field becomes editable
//3-Toggle B cell edition (Off) - The B field becomes non-editable
//4-Toggle A+MiddleCell edition (On) - The A and Middle cell will not become editable even with setCanEdit(true) called on their fields.
// The only way to get it back is to toggle the B cell edition again.
public class ListGridEnableDisable {
boolean isHandlerCellEditable = false;
boolean isBCellEditable = false;
ListGrid myGrid = new ListGrid();
ListGridField a1 = new ListGridField("A", "A1");
ListGridField middleField = new ListGridField("Middle", "Middle Cell");
ListGridField b1 = new ListGridField("B", "B1");
IButton toggleAMiddleButton = new IButton("Toggle A+Middle edit");
IButton toggleBButton = new IButton("Toggle B cell edit");
public void onModuleLoad() {
String var = "";
try {
var = DOM.getInnerHTML(DOM.getElementById("listgrid_test "));
} catch (Throwable e) {
var = "";
}
if(!var.equalsIgnoreCase("listgrid_test_entrypoint "))
return;
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
toggleAMiddleButton.setWidth(200);
toggleAMiddleButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
a1.setCanEdit(!isHandlerCellEditable);
middleField.setCanEdit(!isHandlerCellEditable);
isHandlerCellEditable = !isHandlerCellEditable;
}
});
toggleBButton.setWidth(200);
toggleBButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
b1.setCanEdit(!isBCellEditable);
isBCellEditable = !isBCellEditable;
}
});
myGrid.setFields(a1, middleField, b1);
myGrid.setWidth100();
myGrid.setHeight100();
myGrid.setCanEdit(true);
a1.setCanEdit(false);
middleField.setCanEdit(false);
b1.setCanEdit(false);
createContent();
layout.addMembers(myGrid, toggleAMiddleButton, toggleBButton);
RootPanel.get().add(layout);
}
private void createContent()
{
//Add records
ListGridRecord myRecords[] = new ListGridRecord[3];
myRecords[0] = new ListGridRecord();
myRecords[0].setAttribute("A", "r1 data");
myRecords[0].setAttribute("B", "r1 data");
myRecords[1] = new ListGridRecord();
myRecords[1].setAttribute("A", "r2 data");
myRecords[1].setAttribute("B", "r2 data");
myRecords[2] = new ListGridRecord();
myRecords[2].setAttribute("A", "r3 data");
myRecords[2].setAttribute("B", "r3 data");
myGrid.setData(myRecords);
}
}
I have placed a breakpoint in the toggle handler before executing step #4 described above, and I see that setCanEdit(true) is called on both A and Middle cells, however, trying to edit the cells afterwards is not possible.
I am using smartGWT 3.1 and I also tried the latest 4.0 recently and I have the same behavior. I am using Firefox and Chrome and both have the same behavior.
Thank you