hi
i have a XamDataGrid, whose FieldLayout i have to set in code behind.
the Layout has came from some other objects as property.
like
{
grid.FieldLayouts.Add(newLayout);
grid.DefaultFieldLayout = newLayout;
grid.FieldLayouts.Remove(oldLayout);
}
SetGridLayout(
this.DetailGrid, dlg.UnSelectedFieldLayout);
Hello,
Could you please point out where the problem is?
hi Alex,
i got error on line
grid.FieldLayouts.Add(newLayout); in above code of piece from Method
SetGridLayout(....)
thanx
Laki
Laki,
Please specify what exactly is the error/ exception (NullReference,ArgumentOutOfRangeException,etc.)
Also note that you would have to rebind the grid in order to change the layout.
I am also not sure what this line does:
FieldLayout gridFieldLayout = e.OriginalSource as FieldLayout; // contain the Layout of Grid from Picker Page
Hi Alex,
the error i gor is "Fieldlayout can not be move to another DataPresenterBase.
yes i do bind the data source of Grid. the line you mentioned, contains the Layout from another page/object which i want to apply for my grid in Main Page.
laki
I am attaching a sample that I made trying to reproduce this problem.
Let me know what is different in your scenario.
Alex
Alex,
Thanks for your sample. What we really looking for is to use a Fields Layout between two grids. We know if we create a field Layout in a resource we can reuse it but our case is different.
We have a selected and un selected grid and want to provide the same layout for them so what we do is
Allow user to set the FieldLayout for the selected grid , now we do something like
XamDataGrid selectedgrid
XamDataGrid unselectedgrid
FieldLayout selectedgridLayout = selectedgrid.DefaultFieldLayout;
unselectedgrid.DefaultFieldLayout = selectedgridLayout;
we get the error mentioned (Can not copy field layout)
We do understand that if FieldLayout is attached to one grid we can not reuse it for another grid what we are looking for is a method
to copy FieldLayout from currently displayed grid
Any suggestions are apppretiated
Thanks for the additional information and clearing that up. In this case, I would recommend using the Save and LoadCustomizations method of the XamDataGrid.
Please follow this link on more information about these methods in our help(Save, Load) or in the Andrew Flick blog post:
http://forums.infragistics.com/wpf/codesamples/archives/79116.aspx
Let me know if you have any questions on this.
thanks for reply.
one thing i notice after loading customisation i try to see the value of FieldLayout in
xamDataGrid2_AssigningFieldLayoutToItem(...)
it's field=0 ;
below is the code i used
myClickEvent {
using
(FileStream fs = new FileStream("xamDataGridLayout1.xml", FileMode.Open, FileAccess.Read))
this.xamDataGrid2.LoadCustomizations(fs);
xamDataGrid2.DataSource = people;
e)
regards,
I am working on that. I am not sure about the reason why that it is not working.
i didn't any update on last reply from "rvaid".
The solution you provided does not work for me. What am I missing? Please see the attached sample zip (original your zip) with my modified code.