actionBegin property throwing error

Hi,

 When using syncfusion grid with react and typescript, I'm facing the below issue,

Type '(args: IIndexable) => void' is not assignable to type 'EmitType<PageEventArgs | GroupEventArgs | FilterEventArgs | SearchEventArgs | SortEventArgs |

... 4 more ... | ActionEventArgs>'.


I have a grid where I mentioned 'actionBegin' property,

 <GridComponent

dataSource={tabledata}

columns={currentColumns}

allowSorting={true}

allowPaging={true}

ref={grid}

actionBegin={onActionBegin}

pageSettings={{ pageCount: 10, pageSizes: [10, 20, 'All'] }}

showColumnChooser={true}

allowResizing={true}

allowTextWrap={true}

min-Width

rowHeight={60}

filterSettings={FilterOptions}

allowFiltering={true}

  >


  const onActionBegin = (

    args: IIndexable

  ) => {

    if (args?.requestType === 'filterbeforeopen' && args.columnName === 'companyNames') {

      args.filterModel.options.dataSource = companyNames

    }

  }


  So, the error is thrown only when I specify a particular type for 'args' param, but when I use typeDef of 'args' as 'any' instead of my own reference type, its working fine.

  But, I can't use 'any' since I want to specify the expected/actual typedef for 'args' in the onActionBegin function.


  I already tried with different types for 'args' param including 'FilterSearchBeginEventArgs'

  and all the other types mentioned in the error as expected types (GroupEventArgs | FilterEventArgs | SearchEventArgs | SortEventArgs) but none resolves my issue.


  Hence, I created my own type reference interface object, with 'any' reference to its properties. I mentioned my 'IIndexable' interface below for your reference.


  interface IIndexable {

[name: string]: any

  }

  In spite of doing all this, I'm not able to fix the error. Please help me in this regard. Thanks



3 Replies

RR Rajapandi Ravi Syncfusion Team August 26, 2021 12:51 PM UTC

Hi ym, 

Greetings from syncfusion support 

We are able to reproduce your reported problem. Currently, we are working on this query and we will update you the details by tomorrow 27th Aug 2021. Until then we appreciate your patience. 

Rajapandi R 




RR Rajapandi Ravi Syncfusion Team August 27, 2021 11:09 AM UTC

Hi ym, 

Thanks for your patience 

After validating further with the source, we have confirmed and logged this as a bug in the component. So, we have considered “Type issue while using Filtereventargs” as a defect and logged a report for the same. We will include the defect fix in our upcoming Sep 8th , 2021 patch release. 

You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 


Regards, 
Rajapandi R 



RR Rajapandi Ravi Syncfusion Team September 3, 2021 02:25 PM UTC

Hi ym, 

Sorry for the inconvenience 

After validating further with the source, we could see that we can resolve the problem by a sample level. To resolve the problem, we need to set the corresponding Type in the actionBegin event of Grid. Please refer the below code example for more information. 

 
const actionBegin = (args?: GroupEventArgs | PageEventArgs | FilterEventArgs) => { //actionBegin event of Grid 
        if((args as FilterEventArgs).requestType as string === 'filterbeforeopen') { 
            ((args as FilterSearchBeginEventArgs).filterModel as ExcelFilterBase).options.dataSource = DataUtil.distinct(sdata, 'ShipCountry', true);  
        } 
   
 

Regards, 
Rajapandi R 


Loader.
Up arrow icon