The rad grid pagination and sorting works only on the 1st click

6 posts, 0 answers
  1. Gayatri
    Gayatri avatar
    3 posts
    Member since:
    Jun 2013

    Posted 14 Apr 2014 Link to this post

    I am creating the entire grid on the server side and I have made allowpaging=true and allowsorting=true. But the paging and sorting works only on the 1st click. Even the inbuilt filter works only for the 1st time and afterwards it doesn't work.  Viewstate of the grid is set to true. IF I mark the viewstate as false ,then the pagination and other inbuilt functionality doesn't work even for once. I tried to set the event "OnNeedDataSource" but my rad grid doesn't have the event itself.

    The product version of teh telerik.web.UI dll is- 2012.2.607.35

    Please let me know what am I doing wrong?
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 14 Apr 2014 Link to this post

    Hi Gayatri,

    I supposed that the grid is populated through simple data binding calling DataBind() and this leads to the described behavior. Keep in mind that if you choose simple data-binding, you will need to assign data-source and rebind the grid after each operation (paging, sorting, filtering, etc.) - this copies exactly MS DataGrid behavior.     

    Therefore, I would recommend you subscribe to NeedDataSource event handler prepare the data source (list of objects) for Telerik RadGrid and assign it to the grid's DataSource property as it is shown in this online example:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/simple-vs-advanced/defaultcs.aspx

    Note that OnNeedDataSource event is available in 2012.2.607.35 version of Telerik UI controls for ASP.NET AJAX. Can you make sure that you have reference to Telerik.Web.UI.dll in your project?

    Regards,
    Pavlina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Gayatri
    Gayatri avatar
    3 posts
    Member since:
    Jun 2013

    Posted 14 Apr 2014 in reply to Pavlina Link to this post

    I am binding the grid after each operation, but it never reflects the right page. Moreover I am referencing the dll mentioned by you, still I do not get the ""OnNeedDataSource" event for the rad grid. That puzzles me even more.
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 17 Apr 2014 Link to this post

    Hello,

    Could you please share the problematic code with us, so we can test it locally and advice you further?

    Regards,
    Pavlina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Gayatri
    Gayatri avatar
    3 posts
    Member since:
    Jun 2013

    Posted 20 Apr 2014 in reply to Pavlina Link to this post

    As I mentioned earlier I am not able use the "OnNeedDataSource" event, as I do not get this event with the dll I am using. Ideally I should get the event ,but surprisingly the dll does't have the event.  "viewstate" property for the grid is set yo true. If I set it to false , then the inbuilt properties do not work at at, not even on the 1st click. The grid is created on run time(Server side). There is no aspx page code for it. Please suggest what do I need to do?
    Below code is what I am calling on pageindexchanged-
    Protected Sub _gridControlRadGrid_PageIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs)
                LoadDataForRadGrid()
            End Sub

    Private Sub LoadDataForRadGrid()
                Try


                    Me._gridControlRadGrid.DataSource = ReportDataView
                    _gridControlRadGrid.CurrentPageIndex = _gridControlRadGrid.MasterTableView.CurrentPageIndex
                    '_gridControlRadGrid.Rebind()
                    _gridControlRadGrid.MasterTableView.VirtualItemCount = ReportDataView.Count

                    Me._gridControlRadGrid.DataBind()
                Catch ex As Exception

                End Try
            End Sub
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 23 Apr 2014 Link to this post

    Hello,

    I have tested the described scenario using the 2012.2.607 version of Telerik UI controls and NeedDataSource event fires as expected. Give it a try and see what is the difference on your end.

    Regards,
    Pavlina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top