Strange Behavior in Hierarchical DataGrid

14 posts, 1 answers
  1. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 16 Jun 2011 Link to this post

    I am having a issue displaying data from a dataset to a Hierarchical RadGrid. I have created a small solution that will display the issue, but I have no way of posting it. the solution is a n-teir solution and a website that is built to use user controls to build and display the data. I am defining the hierarchical datagrid in a .cs class in my controls folder of the website.

    Data: I have 3 rows of data in the Parent and each row has child records.
    • Row 1 displays properly
    • Row 2 displays properly
    • Row 3 does not display any data until you move to page 2 on the pager control. Incidentally the record ID's for the child records in row 3 begin at 12 and the page size is set for 10 records to be displayed per page.

    I am wondering if there is a problem with my Grid definition class. The Sample DataSet in the DAL appears to be correctly set up but I feel I have overlooked something.

    Let me know how I can upload the solution.

    Edit:
    I did some additional checking and it seems that the grid is loading the data based on the ID of the record rather than the row number.
    On Row 2 the child table ID's are 5 - 11. I have 10 records being displayed per page. Records 5-10 display on the first page. If I change the Page size to 5 then 1 record displays, the record with the ID 5. I am assuming I have missed some setting on the grid definition else this is a really bad defect.
  2. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 20 Jun 2011 Link to this post

    Bump
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 21 Jun 2011 Link to this post

    Hello Tim,

    Can you please verify that you have no DataBind() calls somewhere in your code? Please, take into account that grid hierarchy is not supported with simple binding and DataBind() calls. For advanced features like hierarchy presentation RadGrid requires advanced data-binding through its NeedDataSource event:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx

    Regards,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 21 Jun 2011 Link to this post

    That is correct. No DataBind() calls. I am using the NeedDataSource(). Your link makes perfect sense but I also saw on one of the other examples (http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/autogeneratedhierarchy/defaultcs.aspx) where you could bind to a Dataset which is nice it you are retrieving a small set of data for read only purposes. Are you saying that Dataset binding does not work with Hierarchical display?
  6. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 21 Jun 2011 Link to this post

    Ok, Here is what I have now. Using the GridDefination class, if I remove the line AllowPaging = true, the grid will work properly. However, with this enabled I get the behavior described above.

    It appears that the record counter for the paging of the grid is using the recordID rather than a positional auto-generated row number of the child datagrid to control the paging.

    I was able to replicate this behavior by adding paging to the asp generated control as well.
    <telerik:RadGrid ID="BatchHistoryRadGrid" runat="server" OnNeedDataSource="BatchHistoryRadGrid_NeedDataSource"
        OnDetailTableDataBind="BatchHistoryRadGrid_DetailTableDataBind"
    AutoGenerateHierarchy="True" CellSpacing="0" GridLines="None"></telerik:RadGrid>


    internal static RadGrid GridDefinition()
    {
        RadGrid _batchHistoryRadGrid = new RadGrid
                                           {
                                               ID = "BatchHistoryRadGrid",
                                               Width = Unit.Percentage(98),
                                               Height = Unit.Pixel(460),
                                               PageSize = 10,
                                               //AllowPaging = true,
                                               AllowSorting = true,
                                               AutoGenerateColumns = false,
                                               ShowStatusBar = true,
                                               Skin = "Web20",
                                               GridLines = GridLines.None,
                                               AutoGenerateEditColumn = false,
                                               AutoGenerateDeleteColumn = false,
                                               HeaderContextMenu =
                                                   {
                                                       Enabled = true,
                                                       CssClass = "GridContextMenu GridContextMenu_Web20"
                                                   },
                                               PagerStyle = {Mode = GridPagerMode.NextPrevNumericAndAdvanced },
                                               ClientSettings =
                                                   {
                                                       Scrolling = {AllowScroll = true, UseStaticHeaders = true},
                                                       Selecting = {AllowRowSelect = true},
                                                       AllowExpandCollapse = true,
                                                   },
                                               FilterMenu = {EnableImageSprites = false},
                                               MasterTableView =
                                                   {
                                                       PageSize = 10,
                                                       CommandItemDisplay = GridCommandItemDisplay.Top,
                                                       EnableHeaderContextMenu = false,
                                                       HorizontalAlign = HorizontalAlign.NotSet,
                                                       HierarchyLoadMode = GridChildLoadMode.Client,
                                                       DataKeyNames = new string[] {"BatchID"},
                                                   },
                                           };
     
     
        GridBoundColumn _masterBoundColumn = new GridBoundColumn
                                                 {
                                                     DataField = "BatchID",
                                                     HeaderText = "BatchID",
                                                     UniqueName = "BatchID",
                                                     HeaderStyle = { Width = Unit.Percentage(33) },
                                                     ItemStyle = { Width = Unit.Percentage(33) },
                                                     ReadOnly = true,
                                                     Visible = false,
                                                 };
        _batchHistoryRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
        _masterBoundColumn = new GridBoundColumn
                                 {
                                     DataField = "BatchName",
                                     HeaderText = "Batch Name",
                                     UniqueName = "BatchName",
                                     HeaderStyle = { Width = Unit.Percentage(33) },
                                     ItemStyle = { Width = Unit.Percentage(33) },
                                     ReadOnly = true,
                                 };
        _batchHistoryRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
        _masterBoundColumn = new GridBoundColumn
                                 {
                                     DataField = "Description",
                                     HeaderText = "Batch Description",
                                     UniqueName = "BatchDescription",
                                     HeaderStyle = { Width = Unit.Percentage(33) },
                                     ItemStyle = { Width = Unit.Percentage(33) },
                                 };
        _batchHistoryRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
        _masterBoundColumn = new GridBoundColumn
                                 {
                                     DataField = "Status",
                                     HeaderText = "Current Status",
                                     UniqueName = "Status",
                                     HeaderStyle = { Width = Unit.Percentage(33) },
                                     ItemStyle = { Width = Unit.Percentage(33) },
                                     ReadOnly = true,
                                 };
        _batchHistoryRadGrid.MasterTableView.Columns.Add(_masterBoundColumn);
     
        // (II in hierarchy level) Detail table - Manual Adjustments of the Batch
     
        GridTableView _batchHistory = new GridTableView(_batchHistoryRadGrid)
                                          {
                                              DataMember = "History",
                                              AutoGenerateColumns = true,
                                              Width = Unit.Percentage(100),
                                              PageSize = 10,
                                              BackColor = Color.FromArgb(198, 203, 214),
                                              CommandItemDisplay = GridCommandItemDisplay.None,
                                              EnableHeaderContextMenu = false,
                                              HorizontalAlign = HorizontalAlign.NotSet,
                                              HierarchyLoadMode = GridChildLoadMode.Client,
                                          };
     
     
        GridRelationFields _relationFields = new GridRelationFields
                                                 {
                                                     MasterKeyField = "BatchID",
                                                     DetailKeyField = "BatchID"
                                                 };
        _batchHistory.ParentTableRelation.Add(_relationFields);
     
        _batchHistoryRadGrid.MasterTableView.DetailTables.Add(_batchHistory);
        return _batchHistoryRadGrid;
    }
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 21 Jun 2011 Link to this post

    Hi Tim,

    You can bind the hierarchy grid to a DataSet through the NeedDataSource event. In the code of the NeedDataSource handler you should prepare the dataset (list of objects) for the RadGrid and assign it to the grid's DataSource property.

    Note that You should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data-binding through NeedDataSource.

    Best wishes,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 21 Jun 2011 Link to this post

    Not using DataBind() or ReBind(). I also updated my previous post with some additional observations.
  9. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 22 Jun 2011 Link to this post

    Bump
  10. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 24 Jun 2011 Link to this post

    Hello Tim,

    Thank you for providing additional information.

    Our development team investigated the issue and they confirmed that autogenerated hierarchy with paging is not a supported scenario with RadGrid - we will be entering this piece of information into our help documentation.

    Greetings,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  11. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 24 Jun 2011 Link to this post

    Will this be a feature added to upcoming releases?

    Edit ~
    Also is there a way to set paging on the MasterTable but leave the children unpaged? I only see that AllowPaging is a property of the Master and that property effects the child as well. Can that be overridden?
    Never mind I figured this one out.
  12. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 24 Jun 2011 Link to this post

    Hello Tim,

    As I said in the previous post - autogenerated hierarchy with paging is not supported by our RadGrid control and there is no way to workaround this. Please excuse us for the inconvenience.

    Greetings,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  13. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 28 Jun 2011 Link to this post

    Pavlin,
    If I have a master table containing 5 rows and their associated GridTableViews have 1000 rows per grid you are telling me there is no way to do paging. You say there is no work around for this problem, however there must be a way to allow paging in GridTableView that are children of a MasterGrid row. If not then the RadGrid is worthless to me in my implementation. I have proven this to be an issue not only in Auto-Generated column binding but also in an user defined column binding of a Hierarchical RadGrid so it is not just limited. This makes no sense to me that the RadGrid is dependant on the [recordID] in the dataset  to do the paging rather than a row number of the associated GridTableView. Do you have any suggestions?

    ~Tim
  14. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Jun 2011 Link to this post

    Hello Tim,

    We understand your frustration very well. But I am sorry to say that with the current implementation of autogenerated hierarchy paging functionality is not supported.

    However, you can bind each detail table-view to the desired dataset using the DetailTableDataBind event and then you will be able to allow paging. Please refer to the following online example for more information:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx

    Once again, excuse us for the inconvenience caused.

    All the best,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  15. Tim
    Tim avatar
    60 posts
    Member since:
    May 2011

    Posted 30 Jun 2011 Link to this post

    Thanks Pavlina,
    I was trying to find that actual sample and could never get the right link. I was using DataSets to do Screen Mock ups for the Client
    which is not how I would implement the DAL in production so this will work perfectly when I have a database to connect it to. I did change over my Mock Up code to Datatables and tested it and and it function as expected. Thanks again.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017