The task of inserting the rows is relatively easy. You need to use the GridViewRowCollection
and its methods like:
You can access the GridViewRowCollection
on the level to be modified through the property Rows
of the RadGridViewTemplate
instance that handles the respected level. In case of the second level for example you get the second level template from the ChildGridViewTemplates
property of RadGridVIew
property. The whole idea is that the template hierarchy is organized into "parent-child" manner - the "parent template" has a ChildGridViewTemplates
that on its turn contains the "child" templates.
So the GridViewRowCollection
has a method with the following signature:
|public GridViewDataRowInfo AddNew(GridViewDataRowInfo parent)
where you give the "master" row instance and the method returns a reference to a newly created "child instance". All fields that are generated by the data base like IDs are pre-populated and available
Also you can tune the behavior of the new row through the event DefaultValuesNeeded
event exposed by the RadGridView component.
The delete operation is handled again through the Rows collection with the methods:
|public bool Remove(GridViewDataRowInfo item)
|public void RemoveAt(int index)
Also you can put/execute your logic regarding the child rows in the event RowsChanging
event exposed by the RadGridView
component. You can cancel the update there. Also through the arguments you can see the type of the operation (insert, delete, clear, etc.) and the template that owns the Rows
collection (thus providing the context of the level in the hierarchy).
If there is anything else we can help with, do not hesitate to contact us.
the Telerik team
Check out Telerik Trainer
, the state of the art learning tool for Telerik products.