Hi All,
I'm trying to add sort functionality to a datagrid, which is based on a ResultSet (as opposed to query).
It is quite easy to make the sort work on a query using the dmf:datasortlink.
However, when I change my code such that my data comes from a ResultSet, this approach does not seem to work out
Does the dmf:datasortlink only work on queries?
Or what should I do to make it work with my ResultSet?
Below I have provided both examples, 1) the query that works, and 2) the ResultSet that does not work (In the onInit method I build a single column with three rows, having the values b, a, and c.)
Best Regards, Jakob
-------------------------
1) the query that works
.jsp:
<dmf:datagrid name="dgCustomList" width="100%"
query="select user_name from dm_user where r_is_group = FALSE"
>
<dmf:datagridTh align='left' scope='col'>
<dmf:datasortlink name='sort0' label="Header"
column='user_name' cssclass='doclistbodyDatasortlink' />
</dmf:datagridTh>
<dmf:datagridRow>
<dmf:datagridRowTd>
<dmf:label datafield="user_name" />
</dmf:datagridRowTd>
</dmf:datagridRow>
</dmf:datagrid>
.java:
public void onInit(ArgumentList args)
{
super.onInit(args);
Datagrid dg = (Datagrid)getControl("dgCustomList",Datagrid.class);
dg.getDataProvider().setDfSession(getDfSession());
}
2) the ResultSet that does not work
.jsp:
<dmf:datagrid name="dgCustomList" width="100%"
>
<dmf:datagridTh align='left' scope='col'>
<dmf:datasortlink name='sort0' label="Header"
column='user_name' cssclass='doclistbodyDatasortlink' />
</dmf:datagridTh>
<dmf:datagridRow>
<dmf:datagridRowTd>
<dmf:label datafield="user_name" />
</dmf:datagridRowTd>
</dmf:datagridRow>
</dmf:datagrid>
.java:
public void onInit(ArgumentList args)
{
TableResultSet rsList = null;
ArrayList listRow = null;
rsList = new TableResultSet(new String[] {"user_name"});
listRow = new ArrayList(1);
listRow.add("b");
rsList.add(listRow);
listRow = new ArrayList(1);
listRow.add("a");
rsList.add(listRow);
listRow = new ArrayList(1);
listRow.add("c");
rsList.add(listRow);
super.onInit(args);
Datagrid dg = (Datagrid)getControl("dgCustomList",Datagrid.class);
dg.getDataProvider().setDfSession(getDfSession());
dg.getDataProvider().setResultSet(rsList, null);
}