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

Problem with paging in Radgrid

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thanh
Top achievements
Rank 1
Thanh asked on 22 Oct 2013, 04:13 PM
I have a reference project code by VB and using telerik .NET UI control. But it have a problem in paging. This is my Employee page, it has been divided into pages but when i click on the other page (eg. 2), the data on table only show data in page 1, i set pagesize 10 is DefaultPageSize (there are 18 items in 2 pages).

   
Public Overrides Sub ViewLoad(ByVal e As System.EventArgs)
       Try
           SetGridFilter(rgEmployee)
           Refresh()
           UpdateControlState()
       Catch ex As Exception
           DisplayException(Me.ViewName, Me.ID, ex)
       End Try
   End Sub
 
   Public Overrides Sub ViewInit(ByVal e As System.EventArgs)
       rgEmployee.AllowCustomPaging = True
       rgEmployee.PageSize = Common.Common.DefaultPageSize
       'rgEmployee.ClientSettings.EnablePostBackOnRowClick = True
       InitControl()
   End Sub
 
   Protected Sub InitControl()
       Try
           Me.ctrlMessageBox.Listener = Me
           Me.MainToolBar = tbarLocations
           Common.Common.BuildToolbar(Me.MainToolBar, ToolbarItem.Create,
                                      ToolbarItem.Edit,ToolbarItem.Save,
                                      ToolbarItem.Cancel)
           CType(MainToolBar.Items(3), RadToolBarButton).CausesValidation = True
           CType(Me.MainToolBar.Items(3), RadToolBarButton).Enabled = False
           CType(Me.MainToolBar.Items(4), RadToolBarButton).Enabled = False
           Me.MainToolBar.OnClientButtonClicking = "OnClientButtonClicking"
           'CType(Me.Page, AjaxPage).AjaxManager.ClientEvents.OnRequestStart = "onRequestStart"
       Catch ex As Exception
           DisplayException(Me.ViewName, Me.ID, ex)
       End Try
   End Sub

in refresh() function call rgEmployee.Rebind() and the html

   
<tlk:RadPane ID="RadPane3" runat="server" Scrolling="None">
           <tlk:RadGrid ID="rgEmployee" runat="server" Height="100%">
               <MasterTableView DataKeyNames="ID" ClientDataKeyNames="CODE, EMP_NAME, EMP_AD">
                   <Columns>
                               <%--<tlk:GridClientSelectColumn> data here --%>
                   </Columns>
               </MasterTableView>
           </tlk:RadGrid>
           <Common:ctrlMessageBox ID="ctrlMessageBox" runat="server" />
            
       </tlk:RadPane>
 
   <script type="text/javascript">
       var enableAjax = true;
    
       function onRequestStart(sender, eventArgs) {
           eventArgs.set_enableAjax(enableAjax);
           enableAjax = true;
       }
   </script>


As i mentioned before, this is a reference project so i refer to the other pages which were paging successful, is different in the "CType(Me.Page, AjaxPage).AjaxManager.ClientEvents.OnRequestStart = "onRequestStart"" call javascript at HTML (slightly silly b/c i really don't know much more about telerik control and this is alse the first time i look at vb code so i can't understand well). I added this code into employee codebehind. It event don't show any things avoid the things from masterpage. Does the problem is there?

When i change rgEmployee.PageSize=20 (don't have "CType(Me.Page, AjaxPage).AjaxManager.ClientEvents.OnRequestStart = "onRequestStart""), it shows all data correctly, and chosing pagesize=10 (were supported by radgrid), it showed correctly too into 10 items for each page (i mean page 2 show 8 items)

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 25 Oct 2013, 12:32 PM
Hi Thanh,

If you want to use custom paging, you should have in mind the "VirtualItemCount" property should be set with the correct amount of items, so that the pager should know how many pages there are depending on your current PageSize property.

More information is available at the following help article and online demo:

For your scenario, if you have do not have huge number of records, you could use the default paging of the grid:
rgEmployee.AllowPaging = True
rgEmployee.PageSize = Common.Common.DefaultPageSize

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Thanh
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or