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

Hierarch Selected Item- 3rd Level

6 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Omlac
Top achievements
Rank 1
Omlac asked on 23 Oct 2008, 12:42 PM
I have a hierarch grid with more than 3 levels, i would like to select multi rows using code below. But my problem is whenever i have 3 or more levels the item.selected part doesnt seem to work anymore. Its just working for the first 2 levels.
protected void btnOk_Click(object sender, EventArgs e)
{

Cursor.Current = Cursors.WaitCursor;
/foreach (GridDataItem item in rdgLocation.MasterTableView.ItemsHierarchy){
if (item.Selected)
{

//do something;
}
}
i have tried replacing rdgLocation.MasterTableView.ItemsHierarchy by rdgLocation.MasterTableView and by rdgLocation.Items but it still doesnt work.
Does anyone know what im doing wrong.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Oct 2008, 01:14 PM
Hi,

The RadGrid.Items collection contains all items from all tables in the hierarchical structure of Telerik RadGrid. By simply looping through the collection and based on the Name property that you set for each hierarchy you can access all data-bound items, their controls and so on:

CS:
foreach (GridDataItem item in RadGrid1.Items) 
   if (item.OwnerTableView.Name== "MyTableName") 
   { 
       // if you need you may also check the parent item keys here 
        if ((item.OwnerTableView.ParentItem as GridDataItem).GetDataKeyValue("MyKeyFieldName").ToString() == "some key value") 
        { 
           // operate with the controls in a custom manner 
        } 
   } 
}   


Thanks,
Princy
0
Omlac
Top achievements
Rank 1
answered on 23 Oct 2008, 02:09 PM
Hi Princy
Thank you very much,

On hovering over the rdgLocationItems in debug mode i have realised that the count for the rdgLocation.Items is 96, insteady of 125, the only records counted are those that are at levl 1 and level 2, the rest are not.
same with the count for rdgLocation.MasterTableView.ItemsHierarchy its 96.
Please note that the selected item on the first and secend level are working fine. Could it be that only the first 2 levels are picked by this method.
My code is like this:
foreach (GridDataItem item in rdgLocation.Items)
{
if (item.Selected)
{
try{
if (strCondition == "Locations")
{Session[
"LocationID"] = Session["LocationID"] + item["LocationID"].Text.ToString() + "-" + item["Location"].Text.ToString() + "-" + item["ParentLocationID"].Text.ToString() + ";";
}
else
{
Session[
"LocID"] = item["LocationID"].Text.ToString();
Session[
"LocName"] = item["Location"].Text.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}

}

0
Omlac
Top achievements
Rank 1
answered on 24 Oct 2008, 06:54 AM
Hie Princy
Look at the information on my debug immediate window

?rdgLocation.Items[2]["location"].Text

"Nedbank"

?rdgLocation.Items[2].Selected

false

but Nedbank is a selected row on my grid. this is only happening on rows at the third level and there after.

item.OwnerTableView.Name is returning a space,"", but i can use the one above because im sellection from only one table so im not keen on this.

0
Omlac
Top achievements
Rank 1
answered on 27 Oct 2008, 02:02 PM
I think there is a problem with the control. i Have tried solving this problem many times without success, I hope the Telerik Support will have a serious look at it.

Regards
0
Accepted
Yavor
Telerik team
answered on 27 Oct 2008, 02:29 PM
Hello Omlac,

If the issue persists at your end, please open a formal support ticket, and send us a small working project, demonstrating the setup, as well as the issue.
We will debug it locally, and get back to you with additional information.

Regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Omlac
Top achievements
Rank 1
answered on 28 Oct 2008, 01:32 PM
Good day
My Ticket number is 170379

Thank you very much
Tags
Grid
Asked by
Omlac
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Omlac
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or