I have implemented a valueAccessor
for a specific column in my SyncFusion Grid
as shown below:
export interface GridColumn<idT> {
...
valueAccessor?: (
field: string,
data: GridData<idT>,
column: Column
) => ValueAccessor | string;
}
Here is how the column is defined:
{
field: 'decimalCount',
headerText: 'Decimals',
textAlign: GridTextAlign.Center,
headerTextAlign: GridTextAlign.Center,
width: 50,
editType: GridEditType.NumericTextBox,
valueAccessor: (
field: string,
data: Partial<CustomDataGridData>
): string => data[field] ?? 'N/A',
}
However, I am encountering the following error:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Partial<CustomDataGridData>'.
No index signature with a parameter of type 'string' was found on type 'Partial<CustomDataGridData>'.
In the code file, the valueAccessor
is utilized like this:
<e-column
...
[valueAccessor]="column.valueAccessor ?? null"
>
To resolve this issue, I had to cast the data
object to any
=> (data as any)[field] ?? 'N/A'
, which fixed the problem. However, I am unsure about the underlying reason behind it.