I have auto generated columns on (I want that so the code can be generic, I don't want to specify table names and layout).
I am binding to 3 tables in a DataSet by an Id (PROPERTY_ID) , so there are three levels of nesting.
I am binding to 3 tables in a DataSet by an Id (PROPERTY_ID) , so there are three levels of nesting.
// start code snippet...
x_GRID.AutoGenerateColumns =
true
;
dd.Tables.Add(t);
// PARENT TABLE
dd.Tables.Add(t0);
// CHILD TABLE A
dd.Tables.Add(t1);
// CHILD (CHILD) TABLE B - This is a child of table A
dd.Relations.Add(
new
DataRelation(
"Prop_Params"
, dd.Tables[0].Columns[
"PROPERTY_ID"
], dd.Tables[1].Columns[
"PROPERTY_ID"
]));
dd.Relations.Add(
new
DataRelation(
"Section_Params"
, dd.Tables[1].Columns[
"PROPERTY_ID"
], dd.Tables[2].Columns[
"PROPERTY_ID"
]));
x_GRID.ItemSource = dd;
// end code snippet...
A few questions - I am
in
the DataLoading
event
(see questions
in
comments below)
void
wpfgv_DataLoading(
object
sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
{
var dataControl = (GridViewDataControl)sender;
// 1. ParentRow != null tells me that it is a child table,
// but I need to know which CHILD TableName it is
// So that I can do different things for child table A and child (child) table B
// (like hide a column that child table A has but child table B does not.
// How do I get the TableName of what dataControl is referring to
// (I could not seem to find it in my debugging watches)???
if
(dataControl.ParentRow !=
null
)
{
dataControl.ShowGroupPanel =
false
;
// 2. I "think" because I have AutoGenerateCols = true, datacontrol.Columns = null
// so this crashes if left uncommented...
// just trying to verify my thinking on why it is null.
dataControl.Columns[
"PROPERTY_ID"
].IsVisible =
false
;
// will crash
// 3. x_GRID is the name of my GridView Control.
// While this works, it only hides the PROPERTY_ID of the
// PARENT table column called PROPERTY_ID
// and does NOT hide child columns of the same name (which is exactly
// the opposite of what I want to do).
// Is there a way without setting x_GRID.AutoGenerateColumns = false
// and binding each column
// in code or xaml to hide just columns of the children???
x_GRID.Columns[
"PROPERTY_ID"
].IsVisible =
false
;
}
}
Thanks,
Daryl