I have a ListGrid
, that needs to have the selection fields on the right. Is there a way?
I tried with:
ListGrid listgrid= new ListGrid(){
@Override
public ListGridRecord[] getSelectedRecords() {
ArrayList<ListGridRecord> ret = new ArrayList<ListGridRecord>();
for(ListGridRecord record : this.getRecords()) {
if ("true".equals(record.getAttribute("selected"))) {
ret.add(record);
}
}
ListGridRecord[] returnable = new ListGridRecord[0];
returnable = ret.toArray(returnable);
return returnable;
}
@Override
protected Canvas createRecordComponent(ListGridRecord record, Integer colNum) {
String fieldName = this.getFieldName(colNum);
if (fieldName.equals("selected")) {
DynamicForm form = new DynamicForm();
CheckboxItem select = new CheckboxItem("selected");
select.setWidth("8%");
form.setFields(select);
return form;
}
else {
return null;
}
}
};
However, as I got informed by the error log, its impossible to do such thing in the way i did this, because of reusing the CheckBoxitem
So, is there a clean way for right selected ListGrid
's?
I think you should try reordering the column in the following way:
Here
0
means the very first checkbox column &lastposition
means the last index of grid columns.