We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

"is not a member of type" error while filtering

Hello,


I have bound a list in SfDataGrid as below.


   <Syncfusion:SfDataGrid HorizontalAlignment="Left"

                               UseDrawing="Default"

                               AllowFiltering="True"

                               SelectionMode="Extended"

                               AutoGenerateColumns="True"

                               Height="640"

                               Width="1880"

                               ItemsSource="{Binding PacketItems}">


            <Syncfusion:SfDataGrid.Columns>

                <Syncfusion:GridTextColumn DisplayBinding="{Binding ID}" />


                <Syncfusion:GridTextColumn DisplayBinding="{Binding Path=Data[0]}"

                                           Width="70"

                                           HeaderText="D0" />


                <Syncfusion:GridTextColumn DisplayBinding="{Binding Data[1]}"

                                           Width="70"

                                           HeaderText="D1" />


                <Syncfusion:GridTextColumn DisplayBinding="{Binding Data[2]}"

                                           Width="70"

                                           HeaderText="D2" />


                <Syncfusion:GridTextColumn DisplayBinding="{Binding Data[3]}"

                                           Width="70"

                                           HeaderText="D3" />


                <Syncfusion:GridTextColumn DisplayBinding="{Binding Time}"

                                           Width="150" />

            </Syncfusion:SfDataGrid.Columns>


        </Syncfusion:SfDataGrid>


  

    public class PacketModel : ViewModelBase

    {

        private int _id;

        private string _time;

        private List<byte?> _data;


        public int ID

        {

            get => _id;

            set => SetProperty(ref _id, value);

        }

        public string Time

        {

            get => _time;

            set => SetProperty(ref _time, value);

        }

        public List<byte?> Data

        {

            get => _data;

            set => SetProperty(ref _data, value);

        }

    }

    public class MainWindowViewModel : ViewModelBase

    {

        private ObservableCollection<PacketModel> _packetItems = new ObservableCollection<PacketModel>();


        public ObservableCollection<PacketModel> PacketItems

        {

            get => _packetItems;

            set => SetProperty(ref _packetItems, value);

        }

        public MainWindowViewModel()

        {

            RandomAdd();

        }


        private void RandomAdd()

        {

            for(int i = 0; i<10;i++)

            {

                PacketItems.Add(new PacketModel() { ID = i, Time = DateTime.Now.ToString(), Data = new List<byte?>() });


                for(int x = 0; x <4;x++)

                {

                    PacketItems[i].Data.Add((byte?)x);

                }

            }

        }

    }


The data is connected properly and I have no problems while viewing. But when I want to use the filtering feature, I get an error like the one below.


''Data[3]' is not a member of type 'SfDataGridTrial.PacketModel''


I've included an example for your review. Filtering properties fail only in columns D0 D1 D2 D3.



Attachment: SfDataGridTrial_12f82619.rar

1 Reply 1 reply marked as answer

SJ Sathiyathanam Jeyakumar Syncfusion Team January 6, 2023 07:59 AM UTC

Hi Özgür,

All data operations, such as sorting, grouping, and filtering, are supported when you bind to an indexer property. If these data operations are not working as expected, try setting the UseBindingValue property to 'true' to resolve the issue.

<Syncfusion:SfDataGrid HorizontalAlignment="Left"

                        UseDrawing="Default"

                        AllowEditing="True"

                        AllowFiltering="True"

                        SelectionMode="Extended"

                        AutoGenerateColumns="True"

                        Height="640"

                        Width="1880"

                        ItemsSource="{Binding PacketItems}">

    <Syncfusion:SfDataGrid.Columns>

        <Syncfusion:GridTextColumn DisplayBinding="{Binding ID}" />

        <Syncfusion:GridTextColumn DisplayBinding="{Binding Path=Data[0]}"

                                    Width="70"

                                    UseBindingValue="True"

                                    HeaderText="D0" />

        <Syncfusion:GridTextColumn DisplayBinding="{Binding Data[1]}"

                                    Width="70" UseBindingValue="True"

                                    HeaderText="D1" />


UG Link : https://help.syncfusion.com/wpf/datagrid/data-binding#binding-indexer-properties

Regards

Sathiyathanam


Attachment: SfDataGridTrial_defdfc71.zip

Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon