error on sample row selection

1 Answer 236 Views
Grid
vamaw
Top achievements
Rank 1
Iron
Iron
vamaw asked on 22 Jun 2021, 05:14 AM

Hi,

 

On angular12 i have an error with thi sample

https://www.telerik.com/kendo-angular-ui/components/grid/selection/row-selection/

Error: src/app/app.component.ts:76:13 - error TS2322: Type 'string' is not assignable to type 'SelectableMode'.
76             mode: this.mode,
               ~~~~

  node_modules/@progress/kendo-angular-grid/dist/es2015/selection/types.d.ts:108:5
    108     mode?: SelectableMode;
            ~~~~

Regards

1 Answer, 1 is accepted

Sort by
0
Silviya
Telerik team
answered on 23 Jun 2021, 07:10 AM

Hi Vamaw,

The error points to a mismatch in types. What happens is:

this.selectableSettings = {
            checkboxOnly: this.checkboxOnly,
            mode (expects type 'SelectableMode'): this.mode (is of type 'string'),
            drag: this.drag
};

This is because when we declare

 public mode = 'multiple';

TypeScript dynamically infers that the type of mode is string. What we actually expect for the selectableSettings 'mode' property is type SelectableMode, which is a string literal union type. So if our example is replicated, it may be useful to declare mode like:

public mode: SelectableMode = 'multiple';
// Which is equivalent to: public mode: 'single' | 'multiple' = 'multiple';

I hope this helps. Let me know if I can assist any further.

Regards,
Silviya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
vamaw
Top achievements
Rank 1
Iron
Iron
Answers by
Silviya
Telerik team
Share this question
or