Unhighlight a Row in a rich:ScrollableDataTable
In my application I need a user to be able to select a row in a table. When they are done working with the data from that row they click a cancel/reset button to reset some other page elements. What I开发者_开发问答 need to do is to also have the reset button unhighlight or unselect the highlighted/selected row in the datatable. I have been unable to figure out what to do in my backing bean to get this working.
From my JSP page:
<rich:scrollableDataTable id="adjusterScheduleScrollableDataTableId" height="200px"
width="807px" rows="10" sortMode="single" var="item"
value="#{controller.searchResults}" selectionMode="single"
binding="#{controller.table}" selection="#{controller.selection}">
<a:support event="onRowClick" action="#{controller.enableTools}" reRender="tools"/>
...
multiple columns
...
</r:scrollableDataTable>
<h:panelGroup id="tools">
<h:commandButton id="reset" action="#{controller.reset}" value="Reset" />
</h:panelGroup>
From my backing bean:
private UIScrollableDataTable table;private Selection selection;
...
public String reset(){
//WHAT GOES HERE TO UNSELECT ROW??
}
...
So I managed to figure out the solution to my problem. Im actually suprise no one was able to answer this.
private UIScrollableDataTable table;private Selection selection;
...
public String reset(){
table.setSelection(new SimpleSelection());
}
...
Two things need to be cleared, the active row and selected row.
private UIScrollableDataTable table;
table.setActiveRowKey(-1);
((SimpleSelection)table.getSelection()).clear();
精彩评论