GrapeCity / ComponentOne-MAUI-Samples

3 stars 4 forks source link

FlexGrid ios binding to a dataview problem #8

Open enkaradag opened 7 months ago

enkaradag commented 7 months ago

Hi

Below code (simply binding a DataView to a FlexGrid) shows all rows but all are empty for iOS. I tested flexgrid lots of times for ios, it was working with ItemSource = DataView before.

For winui and android, same code works, rows are drawn correctly

FlexGrid grid=new FlexGrid(){HeightRequest=500, grid.AutoGenerateColumns = false};
...
DataTable DT=new DataTable();
DT.Columns.Add("FIELD1",typeof(string));
DT.Columns.Add("FIELD2",typeof(string));

DT.Rows.Add("FIELD1_DATA1","FIELD2_DATA1");
DT.Rows.Add("FIELD1_DATA2","FIELD2_DATA2");

grid.Columns.Add(new GridColumn() {Binding="[FIELD1]",Width=100,ColumnName="FIELD1"};
grid.Columns.Add(new GridColumn() {Binding="[FIELD2]",Width=100,ColumnName="FIELD2"};
grid.ItemsSource=DT.DefaultView;

Edit : Bindings are in [ ]. It's still not working for ios

Am i missing something for IOS?

Regards

Ender

arivoir commented 7 months ago

Hi @enkaradag , I'm not sure what is the issue you're seeing (I'm having trouble to connect with mac right now), but to bind a DataTable to FlexGrid in Maui it's better to use the adapter so every feature like sorting, filtering, editing is performed as expected.

grid.ItemsSource = new C1BindingListDataCollection(DT.DefaultView);

You'll need to add the package

<PackageReference Include="C1.DataCollection.BindingList" Version="8.0.20233.180" />

arivoir commented 7 months ago

Hi @enkaradag , I recover my mac and could connect to it, I see when I use C1BindingListDataCollection everything works as expected, even the column's auto-generation, so you don't need to create the columns manually.

DataTable DT = new DataTable();
DT.Columns.Add("FIELD1", typeof(string));
DT.Columns.Add("FIELD2", typeof(string));

DT.Rows.Add("FIELD1_DATA1", "FIELD2_DATA1");
DT.Rows.Add("FIELD1_DATA2", "FIELD2_DATA2");

grid.ItemsSource = new C1BindingListDataCollection(DT.DefaultView);
image