The usage of Grid taglib
This file contains a sample for Grid taglib.
Here we will create a Grid with paging. For paging support we will use
Pager taglib from
Coldtags suite. How it looks like?
In our case we will have a simple array that will be formatted as a grid. And we will
output just 2 rows per page:
<html>
<!-- grid taglib -->
<%@ taglib uri="taglib122.tld" prefix="g" %>
<!-- pager taglib -->
<%@ taglib uri="taglib139.tld" prefix="pg" %>
<!-- our data -->
<%
String a[]={ "A", "B", "C","D" };
%>
<!-- describe paging. Size is 2 records -->
<pg:paging pageSize="2">
<!-- describe our grid -->
<g:grid source="<%=a%>" autoGenerateColumns="false" borderWidth="1">
<!-- headers -->
<g:headers>
<g:column>Data</g:column>
<g:column>Check Box</g:column>
</g:headers>
<!-- rows -->
<g:rows>
<!-- row contains an item for our paging -->
<pg:item>
<form>
<g:column><%=rowData%></g:column>
<g:column><input type="checkbox" name=c<%=rowNumber%>></g:column>
</form>
</pg:item>
</g:rows>
</g:grid>
<!-- index -->
<pg:index title="Pages:">
<pg:page><%=thisPage%></pg:page>
</pg:index>
</pg:paging>
</html>
and you will get some like this:
Data | Check Box |
Pages: | 1 | 2 |
See also Other tips from Coldbeans.