This question is locked. New answers and comments are not allowed.
I have a parent gridview with 2 childrern.
In my parent when it goes to edit mode, my second cell is a drop down of 3 leter port codes "RAB" when the user select a port code in my SelectionChanged event I get the index of the gridview and populate cell 3 and 4 from the object that populated the 3 letter port code drop down.
SelectionChanged event for parent grid.
Now in my second child gridview I want the same functionality, but this time the drop down will be the title field and on selection of this I want the rest of the cells in the second child gridview to be updated.
This is were I am having some difficulties. This is what I have so far in my selectionChanged event, I think my problem is I can not seem to get the correct Index.
And the attached file is what my screen looks like.
Hope this is enough details for some help or advice.
KS.
In my parent when it goes to edit mode, my second cell is a drop down of 3 leter port codes "RAB" when the user select a port code in my SelectionChanged event I get the index of the gridview and populate cell 3 and 4 from the object that populated the 3 letter port code drop down.
SelectionChanged event for parent grid.
private void rcboChgCode_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) { //int CurIdx = gdvTshipRates.Items.IndexOf(gdvTshipRates.CurrentItem); int CurIdx; RadComboBox cmbo = (RadComboBox)sender; var row = cmbo.ParentOfType<GridViewRow>(); if (row != null) { AATshipAgree club = row.DataContext as AATshipAgree; CurIdx = gdvTshipRates.Items.IndexOf(club); if (CurIdx >= 0) { if (e.AddedItems != null && e.AddedItems.Count == 1) { LocationCodeObject lCode = e.AddedItems[0] as LocationCodeObject; AAgentAgreement[CurIdx].DestPortNum = lCode.Loc_Num; AAgentAgreement[CurIdx].DestPortName = lCode.Loc_Name; AAgentAgreement[CurIdx].DestPortCountry = lCode.Loc_Country; } //gdvTshipRates.Rebind(); } else //It's a new row. { //a new item if (e.AddedItems.Count != 0) { CurIdx = AAgentAgreement.Count - 1; LocationCodeObject lCode = e.AddedItems[0] as LocationCodeObject; AAgentAgreement[CurIdx].DestPortNum = lCode.Loc_Num; AAgentAgreement[CurIdx].DestPortName = lCode.Loc_Name; AAgentAgreement[CurIdx].DestPortCountry = lCode.Loc_Country; } } } }This is were I am having some difficulties. This is what I have so far in my selectionChanged event, I think my problem is I can not seem to get the correct Index.
private void rcboRateNotes_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
//int CurIdx = gdvTshipRates.Items.IndexOf(gdvTshipRates.CurrentItem);
int CurIdx;
RadComboBox cmbo = (RadComboBox)sender;
var row = cmbo.ParentOfType<GridViewRow>();
var childGrids = this.gdvTshipRates.ChildrenOfType<GridViewDataControl>();
var item = childGrids[0].SelectedItem;
var item2 = childGrids[1].SelectedItem;
var selectedRow = (GridViewRow)this.gdvTshipRates.ItemContainerGenerator.ContainerFromItem(this.gdvTshipRates.SelectedItem);
var childGrid = selectedRow.ChildrenOfType<GridViewDataControl>().FirstOrDefault();
var childGridcnt = selectedRow.ChildrenOfType<GridViewDataControl>().Count;
//if (childGrid != null)
//{
// childGrid.Columns[1].IsVisible = false;
//}
//if (row != null)
//{
// TShipNote club = row.DataContext as TShipNote;
// // AllRateNotes club = row.DataContext as AllRateNotes;
// CurIdx= gdvTshipRates.Items.IndexOf(club);
// if (CurIdx >= 0)
// {
// if (e.AddedItems != null && e.AddedItems.Count == 1)
// {
// RateNotes lCode = e.AddedItems[0] as RateNotes;
// AllRateNotes2[CurIdx].NoteNum = lCode.NoteNum;
// AllRateNotes2[CurIdx].SecLevel = lCode.SecLevel;
// AllRateNotes2[CurIdx].NoteLevel = lCode.NoteLevel;
// AllRateNotes2[CurIdx].NoteClass = lCode.NoteClass;
// AllRateNotes2[CurIdx].NoteBody = lCode.NoteBody;
// }
// //gdvTshipRates.Rebind();
// }
// else //It's a new row.
// {
// //a new item
// if (e.AddedItems.Count != 0)
// {
// CurIdx = AAgentAgreement.Count - 1;
// RateNotes lCode = e.AddedItems[0] as RateNotes;
// AllRateNotes2[CurIdx].NoteNum = lCode.NoteNum;
// AllRateNotes2[CurIdx].SecLevel = lCode.SecLevel;
// AllRateNotes2[CurIdx].NoteLevel = lCode.NoteLevel;
// AllRateNotes2[CurIdx].NoteClass = lCode.NoteClass;
// AllRateNotes2[CurIdx].NoteBody = lCode.NoteBodyLines2;
// }
// }
//}
}
}
Hope this is enough details for some help or advice.
KS.