3 Answers, 1 is accepted
0
Hi Morten,
Thank you for contacting us.
The approach would depend on the way you are performing CRUD operations in the treelist. If you use automatic operations, you can expand the parent item on ItemInserted event. Then, on PreRender you can select the newly added child item.
If you perform manual operations, you will most probably need to do both things on PreRender but depending on a few other factors, we can move the expand to an earlier event to prevent a second Rebind() of the treelist.
In any case, we would need to know more about your treelist setup in order to give you a working code snippet. Therefore, could you paste your control declaration and describe how you perform inserts in it?
Greetings,
Tsvetina
the Telerik team
Thank you for contacting us.
The approach would depend on the way you are performing CRUD operations in the treelist. If you use automatic operations, you can expand the parent item on ItemInserted event. Then, on PreRender you can select the newly added child item.
If you perform manual operations, you will most probably need to do both things on PreRender but depending on a few other factors, we can move the expand to an earlier event to prevent a second Rebind() of the treelist.
In any case, we would need to know more about your treelist setup in order to give you a working code snippet. Therefore, could you paste your control declaration and describe how you perform inserts in it?
Greetings,
Tsvetina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0

Morten
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 07 Feb 2012, 07:41 PM
Hi Tsvetina
i'm doing insert and updates manually in the InsertCommand and UpdateCommand events.
/Morten
i'm doing insert and updates manually in the InsertCommand and UpdateCommand events.
/Morten
0
Accepted
Hi Morten,
You can do the following on ItemCommand, as long as you use EditForms/PopUp editing :
For InPlace, cast e.Item directly to TreeListDataItem.
As for selecting the inserted child, as the DataKeyValue of the inserted item is usually not known upon insertion, you would need to recognize the item in PreRender by some other value that is available during the insert and select it.
All the best,
Tsvetina
the Telerik team
You can do the following on ItemCommand, as long as you use EditForms/PopUp editing :
int
? parentIndex =
null
;
protected
void
RadTreeList1_ItemCommand(
object
sender, TreeListCommandEventArgs e)
{
if
(e.CommandName == RadTreeList.PerformInsertCommandName)
{
TreeListDataItem item = (e.Item
as
TreeListEditFormInsertItem).ParentItem;
parentIndex = item.DataItemIndex;
}
}
protected
void
RadTreeList1_PreRender(
object
sender, EventArgs e)
{
if
(parentIndex !=
null
)
{
TreeListDataItem parent = RadTreeList1.Items[(
int
)parentIndex];
RadTreeList1.ExpandItemToLevel(parent, parent.HierarchyIndex.NestedLevel + 1);
}
}
For InPlace, cast e.Item directly to TreeListDataItem.
As for selecting the inserted child, as the DataKeyValue of the inserted item is usually not known upon insertion, you would need to recognize the item in PreRender by some other value that is available during the insert and select it.
All the best,
Tsvetina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>