SfDatagrid no content when binding with datatable

hi,

I am using datatable to bind datagrid, everything runs fine on android but on ios the datagrid shows only all the rows with no contents (1st click), only when i click bind the second time  it shows all contents. here it my code:
xaml file:

<radiobutton:SfButton Text="Tìm sản phẩm" 
                              Command="{Binding TimSPTonKho}"/>
        <datagrid:SfDataGrid ItemsSource="{Binding DataTableCollection}" 
                             HorizontalOptions="Center" 
                             AllowTriStateSorting="True" 
                             ColumnSizer="Star" >
            <datagrid:SfDataGrid.Columns>
                <datagrid:GridTextColumn MappingName="TenSanPham"
                                         DisplayBinding="{Binding TenSanPham}" 
                                         TextAlignment="Start">
                    <datagrid:GridTextColumn.HeaderTemplate>
                        <DataTemplate>
                            <Label x:Name="TenSanPham" Text="Tên sản phẩm" TextColor="Black" 
                                   BackgroundColor="WhiteSmoke" VerticalTextAlignment="Center"/>
                        </DataTemplate>
                    </datagrid:GridTextColumn.HeaderTemplate>
                </datagrid:GridTextColumn>
                <datagrid:GridTextColumn MappingName="ID" IsHidden = "True"/>
                <datagrid:GridTextColumn MappingName="TrenDuoi" IsHidden = "True"/>
                <datagrid:GridTextColumn MappingName="SLCL"
                                         AllowSorting="True"
                                         HeaderText= "Số lượng kho"
                                         DisplayBinding="{Binding SLCL}">
                   
                </datagrid:GridTextColumn>

            </datagrid:SfDataGrid.Columns>
        </datagrid:SfDataGrid>

code model file:
class vmThongTinSanPhamTonKho : INotifyPropertyChanged
    {
        private ApiServices _apiServices = new ApiServices();
        public string Loai { get; set; }
        //public vmThongTinSanPhamTonKho()
        //{
        //    DataTableCollection = _DataTableCollection;
        //}
        public DataTable DataTableCollection
        {
            get { return _DataTableCollection; }
            set
            {
                _DataTableCollection = value;
                OnPropertyChanged();
            }
        }

        public DataTable _DataTableCollection;

       
        public ICommand TimSPTonKho
        {
            get
            {
                return new Command(async () =>
                {
                    if (!string.IsNullOrEmpty(Loai))
                    {
                        DataTableCollection = await _apiServices.get_TTSanPham_TonKho(1,Loai, Settings.Accesstoken);
                    }

                });
            }
        }
       
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

5 Replies 1 reply marked as answer

PK Pradeep Kumar Balakrishnan Syncfusion Team June 11, 2020 06:42 PM UTC

HI Tom, 
 
Thank you for contacting Syncfusion support. 
 
Currently, we are analysing the report query. We will validate and update further details in one business days (June 12,2020). We appreciate your patience until then. 
 
Regards, 
Pradeep Kumar B 



TL Tom Lee June 13, 2020 02:00 AM UTC

Hi Kumar Balakrishnan,
Is it a bug or problem with my code  


PK Pradeep Kumar Balakrishnan Syncfusion Team June 15, 2020 12:13 AM UTC

Hi Tom, 
 
Thank you for your patience. 
 
We have checked the reported query “DataGrid column cell value are not rendered in IOS but working in IOS” based on the provided code snippet we have prepared sample and tested the reported query for us in IOS Columns are not rendered even after clicking the button for second time. Please modify the code like following code snippet to resolve this issue. We have removed DisplayBinding settings for DataGrid column. 
 
Code Snippet: 
  <datagrid:SfDataGrid.Columns> 
                <datagrid:GridTextColumn MappingName="TenSanPham" 
                                         TextAlignment="Start"> 
                    <datagrid:GridTextColumn.HeaderTemplate> 
                        <DataTemplate> 
                            <Label x:Name="TenSanPham" Text="Tên sản phẩm" TextColor="Black"  
                                   BackgroundColor="WhiteSmoke" VerticalTextAlignment="Center"/> 
                        </DataTemplate> 
                    </datagrid:GridTextColumn.HeaderTemplate> 
                </datagrid:GridTextColumn> 
                <datagrid:GridTextColumn MappingName="ID" IsHidden = "True"/> 
                <datagrid:GridTextColumn MappingName="TrenDuoi" IsHidden = "True"/> 
                <datagrid:GridTextColumn MappingName="SLCL" 
                                         AllowSorting="True" 
                                         HeaderText= "Số lượng kho" > 
                    
                </datagrid:GridTextColumn> 
 
            </datagrid:SfDataGrid.Columns> 
 
 
We hope this helps. Please let us know if you require any further assistance on this. 
 
Regards, 
Pradeep Kumar B 


Marked as answer

TL Tom Lee June 15, 2020 01:34 AM UTC

Thanks Pradeep Kumar B,

Works perfectly


PK Pradeep Kumar Balakrishnan Syncfusion Team June 15, 2020 05:04 AM UTC

Hi Tom, 
 
We are glad that the given solution meets your requirement.  Please get in touch with us if you would require any further assistance.  
  
Regards,  
Pradeep Kumar B  



Loader.
Up arrow icon