RadGrid GroupBy accessing data

Thread is closed for posting
4 posts, 0 answers
  1. Ben
    Ben avatar
    2 posts
    Member since:
    Jan 2012

    Posted 09 Jul 2013 Link to this post

    I am trying to create an onclick event in the text of the header.  I need data that is in the actual rows that are expanded out of a closed group so i can send it to the javascript function.  I have not been able to find any way to access this data.

    Does anyone have insight as to how to do this?

    Ben
  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 11 Jul 2013 Link to this post

    Hi Ben,

    I am afraid it is difficult to figure out the exact requirement. Can you please elaborate on your specific scenario and provide us sample screenshots or video demonstrating the desired behavior?

    Additionally, you can check out the improved client-side functionality of RadGrid grouping:
    http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/clientsideapi/defaultcs.aspx

    Regards,
    Eyup
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    2 posts
    Member since:
    Jan 2012

    Posted 11 Jul 2013 Link to this post

    Let me try again.

    I have a grid that groups by say "EmployeeName".  I have an ItemDataBound event that fires.  This event fires regardless of whether it is binding a grouping header of a specific data line. So my ItemDataBound looks like:


    So the function belowworks great for the GridDataItem objects because I can pass the "EmployeeID" to this javascript function.  However, when I try to do something similar
    in the GridGroupHeaderItem section I cannot access any data because it is just a header.

    Does this help?

    protected void InternalTrainingGrid_ItemDataBound(object sender, GridItemEventArgs e)
           {
               String ei = "";
               if (e.Item is GridDataItem)
               {
                   GridDataItem dataBoundItem = e.Item as GridDataItem;
                    
                   var x = dataBoundItem["IsManager"].Text;
                   if (Boolean.Parse(dataBoundItem["IsManager"].Text))
                   {
                       dataBoundItem["Institution"].Attributes.Add("onclick", "FocusTraining('" + dataBoundItem["EmployeeID"].Text + "')");
                       ei = dataBoundItem["EmployeeID"].Text;
                   }
               }
               else if (e.Item is GridGroupHeaderItem)
               {
                   GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
                   if (ei != "")
                   {
                       item.DataCell.Text += "<span class='FocusTraining' onclick='FocusTraining(\"" + ei + "\")'>Click Here To See Direct Reports</span>";
                       ei = "";
                   }
               }
           }


  5. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 16 Jul 2013 Link to this post

    Hi Ben,

    I have prepared a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

    Regards,
    Eyup
    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.
Back to Top