PDA

View Full Version : TreeGrid: Hide column checkboxes for certain rows



HerrB
8 Dec 2009, 5:52 AM
Not fully tested, but I haven't found any issues, yet.

Say, you have a TreeGrid with folders and children (leaf) and you have added a CheckColumnConfig to get checkboxes in a column. You don't want to get checkboxes for the folders, only for the leaves:


Folder1
Leaf1 X
Folder2
Leaf2 X
Leaf3 X

You can already disable checkboxes by overriding getCheckState and a -disable text:

CheckColumnConfig objCheckColumn = new CheckColumnConfig("flag", "Flag", 55) {
protected String getCheckState(ModelData objModel, String strProperty, int intRowIndex, int intColIndex) {
if (objModel instanceof FolderModel) {
return "-disable";
} else {
return super.getCheckState(objModel, strProperty, intRowIndex, intColIndex);
}
}
};


You can use this technology also, to hide the checkboxes completely:

CheckColumnConfig objCheckColumn = new CheckColumnConfig("flag", Flag", 55) {
protected String getCheckState(ModelData objModel, String strProperty, int intRowIndex, int intColIndex) {
// In the CheckColumnConfig.onRender method, the returned string is added to the
// term "x-grid3-check-col". See x-grid3-check-col-hidden definition in YOUR css file
if (objModel instanceof FolderModel) {
return "-hidden";
} else {
return super.getCheckState(objModel, strProperty, intRowIndex, intColIndex);
}
}
};

Now add this CSS to your CSS file in the war folder:

.x-grid3-check-col-hidden {
visibility:hidden;
}

Regards,

HerrB