I want to bind DataTable to XamDataGrid.
my Data Table is
DataTable
dt = new DataTable
(); dt.Columns.Add(
dt.Columns.Add(
new DataColumn("Column1", typeof(Object
))); dt.Columns.Add(
new DataColumn("Column2", typeof(Object
)));
DataRow
dr = dt.NewRow(); dr[
dr[
"Column1"] = new TestDTO() { ID = 1, Test123 = "pri"
}; dr[
"Column2"] = new TestDTO() {ID = 1,Test123 ="pri"
}; dt.Rows.Add(dr);
dt.Rows.Add(dr);
dr1 = dt.NewRow(); dr1[
dr1[
"Column1"] = new TestDTO() { ID = 2, Test123 = "Ach"
}; dr1[
"Column2"] = new TestDTO() {ID=2,Test123 ="Ach"
}; dt.Rows.Add(dr1); in my DataGrid have two column 1 is TestDTO and display value is Test123 < igDP:Field Name="Column1" Label="Column 1" > <igDP:Field.Settings > <igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}"
dt.Rows.Add(dr1);
in my DataGrid have two column 1 is TestDTO and display value is Test123
<
igDP:Field Name="Column1" Label="Column 1" >
<igDP:Field.Settings
>
}">
and second one is
="Visible"
=Column2}"
="Test123" />
="True" />
<!--<Setter Property="DropDownButtonDisplayMode" Value="Always" />-->
="Destination_EnterKeyPress"/>
I want to bind DataTable to Grid.
The column DataType should testDTO and display value is test123
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and it seems like I am missing something about your issue, so could you please send me an isolated sample project and screenshots of the desired result, so I can investigate this further for you.
Feel free to write me if you have further questions.
Could you please let me know how can I bind a dataTable to a xamDatagrid.
Below is the XAML:
<igDp:XamDataGrid Grid.Row="1" Name="ODataGrid" DataSource="{Binding Items, UpdateSourceTrigger=PropertyChanged}" Theme="Office2k7Blue"> <igDp:XamDataGrid.FieldLayoutSettings> <igDp:FieldLayoutSettings AutoGenerateFields="True" AutoArrangeCells="Default" AllowFieldMoving="No" AllowAddNew="True" AllowDelete="True" AddNewRecordLocation="OnBottomFixed"/> </igDp:XamDataGrid.FieldLayoutSettings> </igDp:XamDataGrid>
Items is instance of DataTable.DefaultView, so its of type DataView.
Issue: I don't see the grid at all in the window.
Hello Ravi,
Thank you for your post. I have been looking into and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Hello Stefan,
In our setup new columns are added to data table after grid initialization. But these new colums are not updated in the view. Do you have any sample example for that. Basically after grid initialization any change in datatable is not getting reflected on view. Please share example. Thanks in advance.
Actully we able to update cell value but new columns and new rows are not added to view. Actually we are adding rows/columns dynamically. We able to see change in datatable but that change is not reflected on GUI.
Hello Harsh,
Thank you for your post. I have been looking into it and I created a sample project following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Hi Stefan,
Thanks for the sample. It worked. Earlier we were updating datatable from worker thread.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.