-
1. Re: get sorted data out of datatable
steverar Feb 2, 2012 4:07 PM (in response to steverar)Essentially gave up. Was able to see the sorted rowKeys in _modelMaps on the server side but could not access .
Got the source distribution and tried altering the source but maven had build errors and I didn't bother with trying to track that down. Couldn't find a dependacy list.
Ended up having javascript go after the sorted table in the DOM ( form1:DataTableId:tb ) and passing that through h:inputHidden to the server side for processing.
-
2. Re: get sorted data out of datatable
jbosscommunity13 Aug 28, 2012 7:20 AM (in response to steverar)Is there not another way of getting the sorted keys in your hands?
Don't want to build JS to solve something that is already there on server side.
Anybody out there got an solution?
-
3. Re: get sorted data out of datatable
ajanz Aug 28, 2012 7:28 AM (in response to jbosscommunity13)take a look at
https://community.jboss.org/wiki/HowToGetFilteredDataFromTableToList
it helped me getting sorted data from extendeddatatable
-
4. Re: get sorted data out of datatable
jbosscommunity13 Aug 28, 2012 11:05 AM (in response to ajanz)Hi Sascha,
I have found the same Link in the internet, but it explains ho to get FILTERED data, I need access to the SORTED data.
I did it by reflexion:
UIExtendedDataTable edt = (UIExtendedDataTable)FacesContext.getCurrentInstance().getViewRoot().findComponent(componentId); if(edt != null) { int index0Based = edt.getFirst(); Field privateExtendedDataModelField; try { privateExtendedDataModelField = UIDataAdaptor.class.getDeclaredField("extendedDataModel"); if(privateExtendedDataModelField != null) { privateExtendedDataModelField.setAccessible(true); Object o = privateExtendedDataModelField.get(edt); /** SORTING */ if(o instanceof org.richfaces.model.ArrangeableModel){ org.richfaces.model.ArrangeableModel model = (org.richfaces.model.ArrangeableModel)o; if(model != null){ Field rowKeysField = org.richfaces.model.ArrangeableModel.class.getDeclaredField("rowKeys"); rowKeysField.setAccessible(true); List rowKeys = (List)rowKeysField.get(model); // SORTED LIST EXIST if(rowKeys != null && rowKeys.size() > 0){ [...]
its pretttttyyyyy ugly, but it works for now, for more elegant solutions, bring them up!
-
5. Re: get sorted data out of datatable
jbosscommunity13 Aug 29, 2012 7:10 AM (in response to ajanz)how didi it help you?
-
6. Re: get sorted data out of datatable
ajanz Aug 29, 2012 11:16 AM (in response to jbosscommunity13)i changed to the ModifiableModel
wrote this simple function
model.walk(FacesContext.getCurrentInstance(),
newDataVisitor() {
public voidprocess(FacesContext context, Object rowKey, Object argument) {
if ( model.getRowData()!= nullmodel.setRowKey((String)rowKey);
) {
filteredData.add((Data) model.getRowData());
}
}
},
new SequenceRange(0, -1), null);
return filteredData;}
In the bean where i needed the sorted data
List<Data> hitlist = getSortedData( myBean.getDataModel());
sure, not that simple. i never would have found this out without the tips from link above