I really could use some help with this. In 20 years I haven't struggled like
this. I posted this a couple of days ago and haven't received a response.
Perhaps I didn't include enough information. I am working with a tomahawk
datatable and scroller. I started with the cars example. When the row
count changes (rows are selected via a checkbox and then removed from the
list) I reset the first() to 0. That works well. But if I deleted 90 of
100 rows I still show 9 page links until I click something on the scroller.
I'm only using the searchTable to reset the pageIndex to 0. If I could get
the # of page count links to match the row count I think I'm done. Thanks
in advance for any help.
<t:dataTable
id="data"
value="#{carBB.searchResults}"
binding="#{carBB.searchTable}"
var="content"
rows="10"
width="100%"
sortColumn="#{carBB.sort}"
sortAscending="#{carBB.ascending}"
styleClass="table-background"
headerClass="table-header-row"
rowClasses="results_white,results_green"
columnClasses="int_container_text_left"
preserveSort="true">
<t:dataScroller id="scroll_1"
for="data"
fastStep="10"
rowsCountVar="rowsCount"
pageCountVar="pageCount"
pageIndexVar="pageIndex"
styleClass="scrollerTable"
paginator="true"
paginatorMaxPages="9"
paginatorTableClass="paginator"
paginatorActiveColumnStyle="font-weight:bold;"
actionListener="#{carBB.scrollerAction}"
>
In my bean (session scope) I have
private Map _filteredSearchResultsMap = new HashMap();
private List _searchResults = new ArrayList();
public UIData getSearchTable() {
return searchTable;
}
public void setSearchTable(UIData searchTable) {
this.searchTable = searchTable;
}
public List getSearchResults() {
if ( _filteredSearchResultsMap.isEmpty() ){
_searchResults.clear();
}
else{
sort(getSort(), isAscending());
}
return _searchResults;
}
// if the checkbox has been clicked
public void setSearchResults(List searchResults){
for (int i=0;i<searchResults.size();i++){
CARValueObject vo = (CARValueObject) searchResults.get(i);
CARValueObject mapVO = (CARValueObject)
_filteredSearchResultsMap.get(vo.getContentID());
mapVO.setSelected(vo.isSelected());
}
// and when they click the add button all of the 'clicked' rows are added to
another table and removed from the _filteredSearchResultsMap
private void addSelected(){
Iterator i = _filteredSearchResultsMap.values().iterator();
while (i.hasNext()) {
CARValueObject vo = (CARValueObject) i.next();
if (vo.isSelected()){
vo.setSelected(false);
_selectedContentMap.put(vo.getContentID(), vo );
i.remove();
}
}
this.searchTable.setFirst(0);
}
protected void sortSelected(final String column, final boolean ascending)
{
Comparator comparator = new Comparator()
public int compare(Object o1, Object o2)
{
CARValueObject c1 = (CARValueObject) o1;
CARValueObject c2 = (CARValueObject) o2;
if (column.equals("episodeReportableName"))
{
return ascending ?
c1.getEpisodeReportableName().compareTo(c2.getEpisodeReportableName()) :
c2.getEpisodeReportableName()
.compareTo(c1.getEpisodeReportableName());
}
.....more of that
_searchResults = new ArrayList(_filteredSearchResultsMap.values())
Collections.sort(_searchResults , comparator);
}
--
View this message in context:
http://www.nabble.com/HtmlDataScroller-and-page-links-tf2707267.html#a7548133
Sent from the MyFaces - Users mailing list archive at Nabble.com.