Programatically Bind HierachicalGrid

5 posts, 0 answers
  1. Phaneendra
    Phaneendra avatar
    27 posts
    Member since:
    Jul 2011

    Posted 22 Jun 2012 Link to this post

    Hi,
    I have a RadGridview, while displays stock data.
    Now, I have list which list which holds Customized Stock List.
    At this point i want to display this Customized stock List under relevant stock data row.
    I'had approached in design time and did the work,but thing is that [+] Symbol is appearing for all the rows. But i need for only those stock rows which has cutomized list.
    I've approached this tutorial. But this is displaying [+] symbol for each row and not able to display relevant data, its displaying raw data. 

    Once Please look into the Issue.
    protected void AddDetailsTable()
            {
                GridTableView gvCylinderList = new GridTableView(gridMapModel);
                gvCylinderList.Name = "gvCylinderList";
                gvCylinderList.AutoGenerateColumns = false;
                gridMapModel.MasterTableView.DetailTables.Add(gvCylinderList);
                GridBoundColumn clName = new GridBoundColumn();
                clName.DataField = "Name";
                clName.HeaderText = "Name";
                gvCylinderList.Columns.Add(clName);
     
                gridMapModel.DetailTableDataBind+=new GridDetailTableDataBindEventHandler(gridMapModel_DetailTableDataBind);
            }

    Above Snippet for programatically adding the row.
    protected void gridMapModel_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
           {
               GridDataItem item = (GridDataItem)e.DetailTableView.ParentItem;
     
               switch (e.DetailTableView.Name)
               {
                   case "gvCylinderList":
                       int mapModelId = Convert.ToInt32(item.GetDataKeyValue("MapModelId"));
                       VesselService vs = new VesselService();
                       List<MapModelCylinder> lst =  GetMapModelCylinderList(vs.GetMapModelsCylinder(mapModelId));
                       if (lst.Count > 0)
                       {
                           e.DetailTableView.DataSource = lst;
                       }
                           break;
               }
           }

    In the above I'm binding the Detail Table View. But its now working properly. Kindly assist me in fixing. 
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 22 Jun 2012 Link to this post

    Hello,

    More about the conventions about how to generate Telerik RadGrid structure programmatically you can find in the online resources below:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultcs.aspx
    http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html (refer to Create hierarchy grid programmatically section)

    All the best,
    Pavlina
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Keith
    Keith avatar
    5 posts
    Member since:
    Mar 2012

    Posted 25 Jun 2012 Link to this post

    Hi Pavina

    I am also using the programmatic binding but now I am struggling to calculate the total column of child RadGrid and display it on a parent Grid, how can I achieve it  

    Thanks


     
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 28 Jun 2012 Link to this post

    Hi,

    Can you elaborate a bit more what exactly you want to achieve?

    Regards,
    Pavlina
    the Telerik team
    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 their blog feed now.
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 28 Jun 2012 Link to this post

    Hello Edward,

    Meanwhile you can examine the forum thread below which elaborates on similar subject:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/totaling-hierarchical-data.aspx

    All the best,
    Pavlina
    the Telerik team
    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 their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017