Custom VirtualLoadMode

5 replies. Last post: September 4, 2014 10:19 PM by Hans Kristian
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
John BoninMember

In my grid I have the following settings:

<LayoutSettings AllowFilter="Yes" AllowGrouping="Yes" AllowSorting="Yes" PagingMode="VirtualLoad"
VirtualLoadMode="Custom" GroupByBoxVisible="False" AllowColumnFreezing="No" AllowColumnMove="Yes"
AllowExport="Yes" AlwaysShowHelpButton="false" AllowSelectColumns="Yes" RowLostFocusAction="NeverUpdate"
AutoFilterSuggestion="True" FilterBarVisible="false" HideColumnsWhenGrouped="No"
InProgressUIBehavior="ChangeCursorToHourGlass" PagingSize="50" ShowFilterStatus="True"
RestoreRowSelection="RootTableOnly" VirtualPageSize="50" PagingExportMode="ExportAllData"
AllowMultipleSelection="No" GroupRowInfoFormatDefault="[caption] : [value] ([count])"
ColumnFooters="Yes" HeaderClickAction="SortSingle" ShowColumnAction="true" RowHeaders="No"
CellClickAction="CellSelect" AutoFitColumns="false">

In the InitializeDataSource event, I get the SortExpression and maxRows and pass those to my database class, so when I display the grid, I see the first 50 rows and I can load more rows 50 at a time with no problems. The problems comes when I load a preview row. The preview row is loaded on demand. Now if I view any of the first 50 rows then I have no problems viewing the preview row, but if I try to view the preview row on the 51st row then I get an error. It appears the problem is the StartRow, is there a way to determine what the StartRow is? A work around is to load the entire recordset but that defeats the purpose of VitualLoading and when you
return 120K records, it takes a while.

So is there a way to determine what the StartRow is for the page you are on or a way to determine the row that
you want to preview and only get that data? The preview row actually is data that is contained in hidden
columns of the grid, but formatted differently.

thanks john

protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
    {
        RDRDetails db = new RDRDetails();
        getSearchCriteria();

        string sortExpression = "";
        if (WebGrid1.RootTable.SortedColumns.Count > 0)
        {
            sortExpression = WebGrid1.RootTable.SortedColumns.GetSortExpression();
            sortExpression = sortExpression.Replace("]", "").Replace("[", "");// String.Replace(String.Replace(sortExpression, "]", ""), "[", "");
        }

        int startRows = 0;
        int maxRows = WebGrid1.VirtualLoadArgs.RequestedRows;
        int intRDRCount = GetRDRCount();

        WebGrid1.VirtualLoadArgs.TotalDataSourceRows = intRDRCount;

        if (WebGrid1.FlyPostBackAction == PostBackAction.Export)
        {
            //max 10,000 rows when exporting the grid
            e.DataSource = GetRDRs(startRows, 10000, sortExpression);
        }
        else if (WebGrid1.FlyPostBackAction == PostBackAction.LoadPreviewRow)
        {
            e.DataSource = GetRDRs(startRows, maxRows, sortExpression);     // This loads every record not the maxrows, it should be getting one!
        }
        else
        {


All times are GMT -5. The time now is 12:26 AM.
Previous Next