This is a migrated thread and some comments may be shown as answers.

Using Virtualization with Grouping with hooks

8 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ofer
Top achievements
Rank 1
Veteran
Ofer asked on 28 Apr 2020, 07:58 PM

I am interested in an example  like https://stackblitz.com/edit/react-ynzwm7-thwt8x

But I want my application to use hooks.

Can Someone make an example like this with hooks please?

 

Thank you much

8 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 29 Apr 2020, 02:01 PM

Hello, Ofer,

I was able to transfer this example to use React Hooks and also added extra functionality to keep the expanded fields inside the state so they are persisted when paging the data:

https://stackblitz.com/edit/react-2ots26-tzddq5?file=app%2Fmain.jsx

Also, the ticket title says Virtualization but the example is with paging, is the paging has to be replaced with virtualization or the real requirement is paging with grouping?

Regards,
Stefan
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ofer
Top achievements
Rank 1
Veteran
answered on 29 Apr 2020, 03:05 PM

No Stefan I need Virtualization without paging. 

I was able to take the paging out of your example so I can use it.

If you could give a hint how to hide the column that is grouped be, that would be perfect.

Example user drops the "Category Name" on the top, "Category Name" column becomes hidden (The value is in the groups)

 

Thank you very much

0
Stefan
Telerik team
answered on 30 Apr 2020, 01:48 PM

Hello, Ofer,

This can be done by having a columns collection and only rendering the columns if they are not part of the group's collection in the data state:

      {columns.map((column,index) => {
        if(!isColumnGrouped(column)){
          return <Column field={column.field} key={index} title={column.title}/>
        }
      })}

 

I modified the example to demonstrate this approach:

https://stackblitz.com/edit/react-2ots26-1u3hhs?file=app/main.jsx

Regards,
Stefan
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ofer
Top achievements
Rank 1
Veteran
answered on 30 Apr 2020, 02:53 PM
Real Cool Thanks
0
Ofer
Top achievements
Rank 1
Veteran
answered on 30 Apr 2020, 04:40 PM

to your example return <Column field={column.field} key={index} title={column.title} filter={column.filter} />

I added filter={column.filter}  and it works fine in stackblitz because there is no typescript. 

When I do it in SPFx webpart, I get tslinter to complain that filter is not a string but "Type 'string' is not assignable to type '"boolean" | "date" | "text" | "numeric"'.ts(2322)
GridColumnProps.d.ts(43, 5): The expected type comes from property 'filter' which is declared here on type 'IntrinsicAttributes & GridColumnProps & { children?: ReactNode; }'"

Any idea how I should phraze it?

Thanks

0
Stefan
Telerik team
answered on 01 May 2020, 01:37 PM

Hello, Ofer,

I can confirm that I was able to observe the same behavior in a TypeScript example.

As a fast workaround, I can suggest using as any:

 <Column field={column.field} key={index} title={column.title} filter={(column.filter as any)}/>;

We will research it in more details next week as now it is a national holiday and we are short staff.

 

Regards,
Stefan
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ofer
Top achievements
Rank 1
Veteran
answered on 01 May 2020, 02:16 PM
Thank you and have a good holiday
0
Stefan
Telerik team
answered on 04 May 2020, 01:48 PM

Hello, Ofer,

Thank you I hope you have a great day as well.

We have logged this in GitHub in order to be tracked easily:

https://github.com/telerik/kendo-react/issues/571

I also updated your Telerik points for bringing this to our attention.

Regards,
Stefan
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Ofer
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Ofer
Top achievements
Rank 1
Veteran
Share this question
or