-
1. Re: programmatically select specific row in scrollableDataTa
ilya_shaikovsky May 4, 2009 5:37 AM (in response to cencil)You could use selection attribute of scrollable table in order to define initial selection as well as for process it on form submit.
-
2. Re: programmatically select specific row in scrollableDataTa
cencil May 4, 2009 12:11 PM (in response to cencil)Thanks for your reply.
I tried to select all row while clicking a button, but the scrollableDataTable do not reflect it, I guess, all row should be selected like pressing Ctrl-A. Below is my code.
backing bean:
...
public Selection getSelection() {
return selection;
}
public void setSelection(Selection selection) {
this.selection = (SimpleSelection) selection;
}
public String takeSelection() {
Iterator keys = getSelection().getKeys();
while (keys.hasNext()){
// TODO this should be the proper way to get selection key value, but don't work >_<
// SimpleRowKey key = (SimpleRowKey)iterator.next();
// TODO I use another way to make it work
Object key = keys.next();
shareHolder = shareHolders.get(Integer.parseInt(key.toString()));
}
return null;
}
public String selectRow() {
selection = new SimpleSelection();
selection.setSelectAll(true);
return null;
}
...
xhtml:
<rich:scrollableDataTable id="shSdt"
value="#{svsShareHolderMaintDetail_backing.shareHolders}"
var="item"
selection="#{svsShareHolderMaintDetail_backing.selection}"
rows="0"
sortMode="single"
width="250px" height="160px"
rowClasses="sdt-odd-row,sdt-even-row">
<a4j:support event="onselectionchange" action="#{svsShareHolderMaintDetail_backing.takeSelection}"
reRender="detail"/>
<rich:column id="name" width="220px" sortBy="#{item.name}" sortOrder="ASCENDING">
<f:facet name="header">
<h:outputText value="Share Holders" />
</f:facet>
<h:outputText value="#{item.name}"/>
</rich:column>
</rich:scrollableDataTable>
<a4j:commandButton id="selectBtn" value="Select"
action="#{svsShareHolderMaintDetail_backing.selectRow}"/>
...
Thanks!