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,
Give us more detailed information on the error?
If you have a sample project that reproduces the problem, please attach it to your next post.
i don't have sample project but scenario is like.
from my main page i open an picker from which i select the dat which has to be displayed in my Grid present on Main Page.
in picker i have grid whose FieldLayOut is dynamic and changeble.
so the present FieldLayOut from Picker i want to apply the same to my Grid on Main Page.
for that i write one eventhandler in my Picker Page, which return the FieldLayout , which i want to apply to the grid on my Main Page.
i try to do this in follwoing code piece.
private
void SetGridLayout(XamDataGrid grid, FieldLayout newLayout)
if ((null != grid) && (null != newLayout))
FieldLayout oldLayout = grid.DefaultFieldLayout;
if (oldLayout != newLayout)
grid.FieldLayouts.Add(newLayout); ///add the Layout Came from Picker page
<summary>
calls the method to set layout of XamDataGrid.
</summary>
<param name="sender"></param>
<param name="e"></param>
FieldLayout gridFieldLayout = e.OriginalSource as FieldLayout; // contain the Layout of Grid from Picker Page
this.DetailGrid, gridFieldLayout);
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:
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 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.
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.