Grid initialization error

Hi

After creating a tab, I called the grid's changeDataSource event and encountered an error.

Image_1133_1709285512732

Image_5026_1709285607005

Image_3470_1709285574160

Image_3565_1709285625804


3 Replies

JS Johnson Soundararajan S Syncfusion Team March 4, 2024 01:44 PM UTC

Hi Renard,


Based on your query, we notice that when you change the data source using changeDataSource method in the onCreatedTab event, a script error is thrown.

We fulfil your requirement by using triggered the changeDataSource method in dataBound event. It's essential to execute the "changeDataSource" method after the grid has been rendered.

Please refer to the below sample and code snippet for more information.
 

Code sample :


app.component.ts

 

 

  dataBound(argsany) {

    if (this.initial) {

      this.initial = false;

      setTimeout(() => {

        let columnsList2any = [

          { field: 'ShipName'headerText: 'Ship Name'type: 'string' },

          { field: 'ShipCity'headerText: 'Ship City'type: 'string' },

          { field: 'ShipCountry'headerText: 'Ship Country'type: 'string' },

        ];

        if (this.grid) {

          this.grid.changeDataSource(undefinedcolumnsList2);

        }

      });

    }

  }

 


Sample Link : 46kyyp (forked) - StackBlitz

 
Please get back to us, if you need further assistance.
 

Regards,

Johnson Soundararajan S



TE techlandandyzhang March 6, 2024 04:19 AM UTC

We found the problem item. When two conditions are met, after using 'changeDataSource', trying Filter does not work. 

1. The data source is empty when FilterSetting is set. 

2. The field has a type of "checkbox".


https://stackblitz.com/edit/angular-ba3qeo-oxvcua?file=src%2Fapp.component.ts,src%2Fapp.component.html

Image_8707_1709698735584



JS Johnson Soundararajan S Syncfusion Team March 8, 2024 02:26 PM UTC

Hi Renard,
 

We reviewed your query, we observe that you have specified the field name for a column of the checkbox type. However, we are unable to filter the column with the "checkbox" type.


For example, We can filter the columns with type of "boolean" and we can use displayAsCheckBox property to display the check box instead of Boolean value.
 

Please refer to the below API link,  sample and code snippet for more information.
 

Code sample :


app.component.ts

 

      {

        field: 'Testing',

        headerText: 'Postal Code ',

        displayAsCheckBox: true,

        type: 'boolean',

      },


Sample : Geyp1c (forked) - StackBlitz

API Link : Column API in Angular Grid API component - Syncfusion
 

Please get back to us, if you need further assistance.


Regards,

Johnson Soundararajan S


Loader.
Up arrow icon