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

get reference to the grid

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 08 Mar 2009, 08:42 PM
I have grid nested inside the nested view template of another grid.

I also have custom filtering implemented in the nested grid where i provide a dropdown in the filtertemplate of the column.
I want to access the nested grid in the selectedindexchanged event for the combobox to set the filter value.

How can I get the reference to the grid.

This is what I am doing right now but I am wondering if there's a better way of doing this.

protected

void RadComboBoxRelatedContacts_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)

 

{

 

RadComboBox list = (RadComboBox)sender;

 

 

string filterExpression = "([RelationType] = '" + list.SelectedValue + "')";

 

 

GridFilteringItem item = (GridFilteringItem)list.NamingContainer;

 

 

RadGrid gridKeyRel = (RadGrid)item.NamingContainer.NamingContainer.NamingContainer;

 

gridKeyRel.MasterTableView.FilterExpression = filterExpression;

gridKeyRel.MasterTableView.Rebind(); 

}


3 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 08 Mar 2009, 09:34 PM
Is this possibly what you're looking for?
http://www.telerik.com/help/aspnet/grid/grdtraversingdetailtablesitemsingrid.html


0
newbie
Top achievements
Rank 1
answered on 09 Mar 2009, 06:50 AM

I don't want to traverse through the items in the grid.

All i need is a reference to the grid so that I can set the datasource of the grid.

 

Is there a way to get reference t the nested grid outside of the grid events or through the selectedindexchanged event of the filter dropdown of the nested grid

0
Sebastian
Telerik team
answered on 09 Mar 2009, 08:39 AM
Hi newbie,

The code from the help topic illustrates how to traverse not only items but detail tables in hierarchy as well. You can use the approach to get a hold on a particular nested table from outside of grid events.

Additionally, you can reference the INamingContainer (which will be the GridDataItem itself) from within the SelectedIndexChanged event of a combobox inside the detail table and then use the OwnerTableView object to obtain the respective child table object.

Review the following examples which elaborate on this subject:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/accessingcellsandrows/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/gridreferencecontrolsinroweditform.html

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
newbie
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or