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

RadGrid GroupBy accessing data

3 Answers 51 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 09 Jul 2013, 06:20 AM
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

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 11 Jul 2013, 10:55 AM
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.
0
Ben
Top achievements
Rank 1
answered on 11 Jul 2013, 08:34 PM

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 = "";
               }
           }
       }


0
Eyup
Telerik team
answered on 16 Jul 2013, 12:16 PM
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.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Ben
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Ben
Top achievements
Rank 1
Share this question
or