Fetch number of records in a FormDataSource (e.g. of a Grid)
May 26, 2011 1 Comment
SysQuery::getTotal works fine, but the trick is how to handle temporary data sources where getTotal does not work:
if(!formDataSource.curser().isTmp())
{
recordCount = SysQuery::getTotal(formDataSource.queryRun());
}
else
{
while(!formDataSource.allRowsLoaded())
{
formDataSource.getNext();
}
recordCount = formDataSource.numberOfRowsLoaded();
}
Now recordCount contains the number of Records in the FormDataSource irrespective of the Tmp status of the data source. Of course the whole tmp-data source has been loaded in the process, which might be an issue in some cases.
Ack. Just had a similar problem to this one as well.
http://axandhellisfunafterall.blogspot.com/2011/09/obtaining-datasource-totals-filtered.html
Didn’t know about the temporary datasource issue. Thanks
Regards