Tag: Grid

  • Fetch number of records in a FormDataSource (e.g. of a Grid)

    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.