Kendo grid columns reorder

1 Answer 90 Views
Grid
-
Top achievements
Rank 1
- asked on 10 Feb 2022, 09:08 AM

Hi!

I'm implementing feature to persist state of grid defined by users and having issue with reorder. The only solution I've found is that. But *ngFor is not very convenient for us because we have a lot of custom templates for columns.  Is there an option to specify column index in html? 

Thank you.

1 Answer, 1 is accepted

Sort by
0
Martin Bechev
Telerik team
answered on 14 Feb 2022, 10:24 AM

Hello,

The Kendo Angular Grid columns could be generated dynamically with *ngFor and templated at the same time. To accomplish such a scenario, the developer needs to define the desired template and toggle the column content visibility with *ngIf directive, for example. 

  <kendo-grid-column
          *ngFor="let column of columns"
          field="{{column.field}}"
          title="{{column.title}}"
        >
        <ng-template kendoGridCellTemplate let-dataItem>
           <div *ngIf="column.field==='ProductName'">
            <strong>{{ dataItem.ProductName }}</strong>
           </div>
          <div *ngIf="column.field!=='ProductName'">
            {{ dataItem.ProductName }}
          </div>
         </ng-template>
        </kendo-grid-column>

Please check the following example which demonstrates the suggestion:

https://stackblitz.com/edit/angular-hpxnp3?file=app/app.component.ts

I hope this helps.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
-
Top achievements
Rank 1
Answers by
Martin Bechev
Telerik team
Share this question
or