public CustomGridDataSource(GridDataSource gds) { super(); this.datas = new ArrayList<Object>(); for(int i = 0; i < gds.getAvailableRows(); i++){ datas.add(gds.getRowValue(i)); } this.cgds = new CollectionGridDataSource(datas); }
public Class getRowType() { return delegate.getRowType(); } }
public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) { delegate.prepare(startIndex, endIndex, sortConstraints); }
final int records = source.getAvailableRows(); source.prepare(startIndex,endIndex,sortModel.getSortConstraints() ); Object obj = source.getRowValue(index); addPartialMarkupRendererFilter(override,source.getRowType() , obj, name, rowIndex, columnIndex, index); }else{ addPartialMarkupRendererFilter(val,source.getRowType() , obj, name, rowIndex, columnIndex, index);
void setupDataSource() { // TAP5-34: We pass the source into the CachingDataSource now; previously // we were accessing source directly, but during submit the value wasn't // cached, and therefore access was very inefficient, and sorting was // very inconsistent during the processing of the form submission. int effectiveCurrentPage = getCurrentPage(); int numberOfRowsRequiredToShowCurrentPage = 1 + (effectiveCurrentPage - 1) * rowsPerPage; int numberOfRowsRequiredToFillCurrentPage = effectiveCurrentPage * rowsPerPage; cachingSource = new CachingDataSource(source); if (pagerPosition != GridPagerPosition.NONE) { // We're going to render the pager, so we need to determine the total number of rows anyway. // We do that eagerly here so we don't have to perform two count operations; the subsequent // ones will return a cached result cachingSource.getAvailableRows(); } int availableRowsWithLimit = cachingSource.getAvailableRows(numberOfRowsRequiredToFillCurrentPage); if (availableRowsWithLimit == 0) return; // This captures when the number of rows has decreased, typically due to deletions. if (numberOfRowsRequiredToShowCurrentPage > availableRowsWithLimit) { int maxPage = ((availableRowsWithLimit - 1) / rowsPerPage) + 1; effectiveCurrentPage = maxPage; } int startIndex = (effectiveCurrentPage - 1) * rowsPerPage; int endIndex = Math.min(startIndex + rowsPerPage - 1, availableRowsWithLimit - 1); cachingSource.prepare(startIndex, endIndex, sortModel.getSortConstraints()); }
/** * Return whether the data source is empty, i.e. does not have any rows available. */ default public boolean isEmpty() { return getAvailableRows(1) == 0; }
public Object getRowValue(int index) { return delegate.getRowValue(index); }
@Override public boolean isEmpty() { if (!emptyCached) { empty = delegate.isEmpty(); emptyCached = true; if (empty) { availableRows = 0; availableRowsCached = true; } } return empty; }
/** * Iterator for the look component in order to loop to each rows */ public Iterable<Integer> getLoopSource() { // Issue #284 : call prepared() before calling getRowValue() int startIndex = 0; int endIndex = getSource().getAvailableRows() - 1; getSource().prepare(startIndex, endIndex, sortModel.getSortConstraints()); return new Iterable<Integer>() { public Iterator<Integer> iterator() { return new Iterator<Integer>() { Integer i = new Integer(0); public boolean hasNext() { return i < getSource().getAvailableRows(); } public Integer next() { row = getSource().getRowValue(i); return i++; } public void remove() { i = 0; } }; } }; }
public int getAvailableRows() { if (!availableRowsCached) { availableRows = delegate.getAvailableRows(); availableRowsCached = true; } return availableRows; }
public Object getRowValue(int index) { return delegate.getRowValue(index); }
Object setupRender() { if (formSupport != null) { formSupport.store(this, SETUP_DATA_SOURCE); } setupDataSource(); // If there's no rows, display the empty block placeholder. return !renderTableIfEmpty && cachingSource.isEmpty() ? empty : null; }
/** * This method will filter all your data by using the search input from your datatable. */ public GridDataSource filterData(GridDataSource source){ final List<Object> datas = new ArrayList<Object>(); for(int index=0;index<source.getAvailableRows();index++){ boolean flag = false; for (Object name: model.getPropertyNames()) { PropertyConduit conduit = model.get((String) name).getConduit(); try{ String val = (String) conduit.get(source.getRowValue(index)); if(val.contains(request.getParameter(DataTableConstants.SEARCH))) flag = true; } catch (Exception e){ } } if(flag){ datas.add(source.getRowValue(index)); } } return new CustomGridDataSource(datas); }
public int getAvailableRows() { if (!availableRowsCached) { availableRows = delegate.getAvailableRows(); availableRowsCached = true; if (availableRows == 0) { empty = true; emptyCached = true; } else { empty = false; emptyCached = true; } } return availableRows; }
/** * Callback method, used when recording state to a form, or called directly when not recording state. */ void setupForRow(int rowIndex) { row = gridModel.getDataSource().getRowValue(rowIndex); }
public Class getRowType() { return delegate.getRowType(); }
public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) { delegate.prepare(startIndex, endIndex, sortConstraints); }
Object beginRender(MarkupWriter writer) { // Skip rendering of component (template, body, etc.) when there's nothing to display. // The empty placeholder will already have rendered. if (cachingSource.isEmpty()) return !renderTableIfEmpty ? false : null; if (inPlace && zone == null) { javaScriptSupport.require("t5/core/zone"); writer.element("div", "data-container-type", "zone"); didRenderZoneDiv = true; // Through Tapestry 5.3, we had a specific id for the zone that had to be passed down to the // GridPager and etc. That's no longer necessary, so zone will always be null or "^". We don't // even need any special ids to be allocated! zone = "^"; } return null; }
/** * Return the number of rows available in the data source with an upper limit. * If determining the total number of rows is expensive, this method should be overridden to provide a more * efficient implementation. * Please note that the default Grid pager will still determine the total number of rows, so for this to have * an effect, a custom pager should be used. * * @param limit the upper limit * @return the number of rows or {@code limit}, whichever is lower */ default public int getAvailableRows(final int limit) { int availableRows = getAvailableRows(); if (availableRows >= limit) { return limit; } return availableRows; }
Object obj = getSource().getRowValue(index);