-
1. Re: scrollableDataTable selection after sorting
ilya_shaikovsky Feb 4, 2008 5:59 AM (in response to clausnyhus) -
2. Re: scrollableDataTable selection after sorting
rulinsun Feb 28, 2008 12:53 PM (in response to clausnyhus)There is workaround to this issue. Actually, I think the way it was used in demo was not right for the selection. Codes to make it works:
In the backbean define:
private HtmlScrollableDataTable selectTable; // binding in scrollableDataTable
private SimpleSelection selection = new SimpleSelection();
private int selectData() {
if(getDataList()==null)return 0;
if(getDataList().size()==1){
// this fix the richFaces bug in case of only one row, selection doesn't work
setSelectedData((ObjectDataType)getDataList().get(0));
return 1;
}
Iterator keys = getSelection().getKeys();
while(keys.hasNext()) {
SimpleRowKey key = keys.next();
getSelectionTable().setRowKey(key);
setSelectedData((ObjectDataType)getSelectTable().getRowData()); }
if(getSelectedData()==null) return 0;
return getSelection().size();
}
}
For multiple selections, change setSelectedData() to getSelectedData().add(). In your action/actionListener to process selectedData, call selectData() first.
But I do find that in order to make sorting, selection, scrolling working, the dataList of the table has to be static data (like all cars in demo), or the bean to hold list has to be in the session scope. If the datalist is retrieved based on the request parameter in the form, it will not work. When I debug, some ajax calls for scrolling, sorting happen before form fields been populated.
Thanks!
Rulin