Hi,
I m showing parent child realtionship in web grid. I hve set Indentation="0" so that it shows common headers for all parent and child. Now when it tried to expand first column then only root elements column gets resized and child column not changing so its looking odd. I want to change width of all clumns simulteneously on changing common header column.So how can i do that.
Please help.
Thanks,
Mahendra.
Hi Mahendra,
Is the data on your Root level and on your ChildBand represented by the same Data object? If so, then you could use the same ColumnLayout for both bands. Which means the data would be represented by the same columns. So when you resize one, the other will be resized. This can be done by using the TargetTypeName property on the ColumnLayout, and defining that ColumnLayout in the grid's ColumnLayouts collection.
So, if you bound your grid to a List<Person> objects, and a Person object has a property called Children, which is has a List<Person> objects, then the Root ColumnLayout and the ChildBand would both be represented by Person objects. Which means you could do the following.
<ig:XamWebGrid>
<ig:XamWebGrid.ColumnLayouts>
<ig:ColumnLayout TargetTypeName="Person" / >
</ig:XamWebGrid.ColumnLayouts>
<./ig:XamWebGrid>
If this is not the case, and you're using the Indicator Resizing, then another option is to use the Events that we provided for ColumnResizing.
-SteveZ
hi,
I tried this in igModelGrid_ColumnLayoutAssigned event. following is the code
e.ColumnLayout.Columns.Add(
new ColumnLayout() { TargetTypeName = "MyData", Key = "lstChildData", HeaderVisibility = Visibility.Collapsed });In my code i hve added TargetTypeName. Is it right or something different to set in codePlease give code how can i do that from code...
Mahendra
If you're data object is of type MyData, then the TargetTypeName is correct.
However, how you're adding it is incorrect.
If you want to use the event, you'd be using it to replace the ColumnLayout that's being created for the root level and the child band, which would mean setting TargetTypeName isn't neccessary.
My recommendation though, is to instead set it in xaml, or before your ItemSource is set in the code behind, by adding it to the grid's ColumnLayouts collection.
ColumnLayout cl = new ColumnLayout(){TargetTypeName="MyData" ....
grid.ColumnLayouts.Add(cl)
Hope this clear things up.
where should i write this code in igList_CellControlAttached event or after igList.Itemsource=lst; statement.
Please tell where to add that code..
You shouldn't be writing that code in the CellControlAttached event. as that event will fire a lot.
Like i said in the previous post. if you're setting it in the codebehind, add the ColumnLayout before you set the ItemSource.
Am I right that it's impossible to hide child rows' column header if the same layout is used for both parent and child rows?
We need to show parent-child orders relationship. Both bound objects are OrderViewModel. So I tried to reuse the same column layout. But we want to have a single column header on the top of the grid which isn't possible I guess.
Correct there is no supported way to withhold the rendering of the header row on the child bands.