Hello
I want to build a hierarchy with a ComboBoxColumn
both the rows of the child grid
and the items of the ComboBoxColumn
need to be filtered
this is the way I work
and now OnChildGridLoaded I get a mistake
for this line
var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext;
Unable to cast object of type 'System.Data.DataRow' to type 'System.Data.DataRowView'.
I want to build a hierarchy with a ComboBoxColumn
both the rows of the child grid
and the items of the ComboBoxColumn
need to be filtered
this is the way I work
and now OnChildGridLoaded I get a mistake
for this line
var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext;
Unable to cast object of type 'System.Data.DataRow' to type 'System.Data.DataRowView'.
| private void BindDataMainGrid() |
| { |
| try |
| { |
| GridViewTableDefinition BudgetTableDefinition = new GridViewTableDefinition(); |
| BudgetTableDefinition.Relation = new PropertyRelation("Budget"); |
| GridViewTableDefinition SubBudgetTableDefinition = new GridViewTableDefinition(); |
| SubBudgetTableDefinition.Relation = new PropertyRelation("SubBudget"); |
| this.gvAccount.ItemsSource = this.GetData(); |
| } |
| catch{} |
| } |
| private void OnChildGridLoaded(object sender, RoutedEventArgs e) |
| { |
| try |
| { |
| var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
| var ds = dataRowView.DataView.Table.DataSet; |
| var childData = dataRowView.CreateChildView(ds.Relations["BudgetRelation"]); |
| //סינון הערכים בגריד לפי סוג פעילות |
| if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
| { |
| childData.RowFilter = "ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| else |
| { |
| ((RadGridView)sender).ItemsSource = null; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| //סינון הערכים בתיבת הבחירה בעמודה של סוג פעילות |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
| } |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
| } |
| } |
| catch { } |
| } |
| private void OnSubChildGridLoaded(object sender, RoutedEventArgs e) |
| { |
| try |
| { |
| var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
| var ds = dataRowView.DataView.Table.DataSet; |
| var childData = dataRowView.CreateChildView(ds.Relations["SubBudgetRelation"]); |
| ((RadGridView)sender).ItemsSource = childData; |
| //סינון הערכים בגריד לפי סוג פעילות |
| if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
| { |
| childData.RowFilter="ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| else |
| { |
| ((RadGridView)sender).ItemsSource = null; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| //סינון הערכים בתיבת הבחירה של סוג פעילות |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
| } |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
| } |
| } |
| catch { } |
| } |
