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

build button link from kendo grid column's fields

1 Answer 1948 Views
Button
This is a migrated thread and some comments may be shown as answers.
LEO
Top achievements
Rank 1
Veteran
LEO asked on 21 Sep 2020, 04:55 PM

 

Hello, 

I'm creating a button inside the grid that will show up inside each row and the link inside the button have to load the data from the column field , as you can see

in bold in this example , how to achieve this please? 

 

 <kendo-grid
          [data]="view | async"
          [height]="833"
          [resizable]="true"
          [pageSize]="gridState.take" [skip]="gridState.skip" [sort]="gridState.sort"
          [pageable]="true" [sortable]="true" [filterable]="true"
          (dataStateChange)="onStateChange($event)"
          (edit)="editHandler($event)" (remove)="removeHandler($event)"
          (add)="addHandler($event)"
        >
        <ng-template kendoGridToolbarTemplate>
            <button kendoGridAddCommand>Add new</button>
        </ng-template>
        <kendo-grid-column [width]="120" field="ID"  title="ID" filter="numeric" ></kendo-grid-column>
        <kendo-grid-column [width]="220" field="user_id" title="User ID"></kendo-grid-column>
     
        <kendo-grid-command-column title="command" width="220">
            <ng-template kendoGridCellTemplate>
                <button kendoButton look="flat" [primary]="true"
                onclick="location.href='https://www.example.net/link-fieldID-fieldUserID'">
                comfirm user</button>
                <button kendoGridEditCommand [primary]="true">Edit</button>
                <button kendoGridRemoveCommand>Delete</button>
            </ng-template>
        </kendo-grid-command-column>
      </kendo-grid>

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Bechev
Telerik team
answered on 22 Sep 2020, 01:38 PM

Hello Leo,

When using a template, the developer has access to the current dataItem, using the dataItem field of the kendoGridCellTemplate:

Here is an example:

https://stackblitz.com/edit/angular-jmhugo?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
Button
Asked by
LEO
Top achievements
Rank 1
Veteran
Answers by
Martin Bechev
Telerik team
Share this question
or