Hi forum, probably this is a stupid issue but I cannot find a clue in the documentation: how comes that the grid does not refresh its display when its underlying data from a DataTable get changed? I describe here a dummy sample to reproduce my issue:
1) in a new WPF application I create a dummy datagrid with 2 fields only, one editable corresponding to a bool field and another non-editable corresponding to a string field:
<igDP:XamDataGrid VerticalAlignment="Stretch" DataSource="{Binding}" x:Name="_dgSample" Margin="2"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True" AllowAddNew="False" AllowDelete="False"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="selected" Label="sel."> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="True" CellWidth="40" LabelWidth="40" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="name" Label="name"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" CellWidth="150" LabelWidth="150"/> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts></igDP:XamDataGrid>
2) in the load event I place this code to create a dummy data source in a DataTable object and bind the grid to it (_dt is a class member of type DataTable):
// create a dummy data table_dt = new DataTable("TSample");DataColumn col;
col = new DataColumn("selected", typeof(bool));col.AllowDBNull = false;col.DefaultValue = false;_dt.Columns.Add(col);
col = new DataColumn("name", typeof(string));col.AllowDBNull = false;col.DefaultValue = "";_dt.Columns.Add(col);
// fill it with some datafor (int i = 0; i < 10; i++){ DataRow row = _dt.NewRow(); row["selected"] = ((i & 1) != 0); row["name"] = i.ToString(); _dt.Rows.Add(row);} //efor_dt.AcceptChanges();
// bind to grid_dgSample.DataSource = new DataView(_dt, "", "name", DataViewRowState.CurrentRows);
When I run the sample I get the grid showing the data as expected. If now I click a button which simply inverts the boolean column value, the grid does not show any change:
for (int i = 0; i < _dt.Rows.Count; i++) _dt.Rows["selected"] = !(bool)_dt.Rows["selected"];_dt.AcceptChanges();
What I'm missing here? Thanx to all!
Hi there
Which version of NetAdvantage for WPF are you running? I just built your sample and the grid is being updated as expected (both NA 7.2 RC and NA 7.1)...
Cheers,
Philipp