SFDataGrid Binding with DataTable issue

Hi,

I'm migrating from Xforms and I have this cose that is working correctly on Xforms but is not working on maui.

Even if I can debug and see that I have data, the grid doesn't display anything.

thanks


public async Task LoadData()

{

await Task.Run(() =>

{

    table = JsonConvert.DeserializeObject<DataTable>(jsonData);

});

Grid.ItemsSource = table;

}


In the page consturctor (code behind) I have

BindingContext = vm;

vm.Grid = dataGrid;

vm.LoadData();


Can you check please?

thanks


3 Replies

SD Sethupathy Devarajan Syncfusion Team September 9, 2024 02:03 PM UTC

Hi Luca,


Based on the provided information, we reviewed your query by fetching data from the API and loading it as a DataTable into the DataGrid's item source. The DataGrid is successfully populated with the data retrieved from the API. We have shared the tested sample for your reference.


Regards,

Sethupathy D.


Attachment: SfDataGridSample_(2)_a9d5e271.zip


LU Luca September 9, 2024 03:33 PM UTC

Hi,

thanks for your quick response.

I fixed thanks.

One more question: there is a lot of space inside cell even if the text is small. Ho can set the cell size in order to occupay the min space needed?

thanks



SD Sethupathy Devarajan Syncfusion Team September 10, 2024 07:50 AM UTC

 

Hi Luca,

The reason for the excessive space inside the cell, even if the text is small, is because in our sample we defined the ColumnWidthMode as 'Auto.' You can set the desired mode based on your needs. We have shared the documentation link for your reference.

 

Ug link : Column-Sizing

Regards,

Sethupathy D.


Loader.
Up arrow icon