This is a migrated thread and some comments may be shown as answers.

RadGrid not saving VirtualItemCount

1 Answer 322 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 20 Nov 2012, 05:57 PM
I have some custom logic that grabs a single page worth of data before setting the datasource of my RadGrid. I set the MasterTableView.VirtualItemCount. However, upon load of the page, It is telling me that I have 4 items in 1 page, thereby not giving me access to further pages. Here is my code:

ASP
<telerik:RadGrid AllowPaging="true"
                AllowSorting="true"
                AutoGenerateColumns="false"
                GridLines="None"
                ID="LoginAuditGrid"
                OnNeedDataSource="LoginAuditGrid_NeedDataSource"
                PageSize="4"
                PagerStyle-AlwaysVisible="true"
                ShowFooter="false"
                ShowGroupPanel="true"
                Skin="Hay"
                runat="server">


                <ClientSettings AllowDragToGroup="true" />
                <GroupingSettings ShowUnGroupButton="true" />


                <MasterTableView AllowMultiColumnSorting="true"
                    AllowSorting="true"
                    CommandItemDisplay="Top"
                    EnableColumnsViewState="false"
                    Font-Size="8">
                    <Columns>
                        <telerik:GridBoundColumn DataField="ApplicationName" DataType="System.String" HeaderText="Application Name" UniqueName="ApplicationID" />
                        <telerik:GridBoundColumn DataField="Username" DataType="System.String" HeaderText="Username" UniqueName="Username" />
                        <telerik:GridBoundColumn DataField="IPAddress" DataType="System.String" HeaderText="IP Address" UniqueName="ApplicationID" />
                        <telerik:GridBoundColumn DataField="LoginAuditDT" DataType="System.DateTime" HeaderText="Login Time" UniqueName="LoginAuditDT" />
                        <telerik:GridBoundColumn DataField="LoginAuditStatus" DataType="System.String" HeaderText="Login Audit Status" UniqueName="LoginAuditReasonID" />
                        <telerik:GridBoundColumn DataField="SecurityUserID" DataType="System.Int32" HeaderText="Security User ID" UniqueName="SecurityUserID" />
                    </Columns>
                    <CommandItemSettings ShowExportToExcelButton="false" ShowAddNewRecordButton="false" />
                </MasterTableView>
            </telerik:RadGrid>

Code Behind
protected void LoginAuditGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
    //This method defines a set of criteria to filter my data on
            BaseSearch criteria = new BaseSearch(SavedSearch);

            List<LoginAuditDetail> data = ServiceProxy.GetService<IAdminService>().FetchLoginAudit(criteria);

            LoginAuditGrid.MasterTableView.VirtualItemCount = ServiceProxy.GetService<IAdminService().FetchLoginAuditCount(criteria);
            LoginAuditGrid.DataSource = data;
        }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Nov 2012, 08:14 AM
Hi,

VirtualItemCount Property Gets or sets a value, indicating the total number of items in the data source when custom paging is used. Thus the grid "understands" that the data source contains the specified number of records and it should fetch merely part of them at a time to execute requested operation.

Please check this help documentation.

Thanks,
Shinu.
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or