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

Multiple clickable icons in grid column

6 Answers 1155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Irina
Top achievements
Rank 1
Irina asked on 13 Sep 2019, 09:02 AM

Hi,

I am using a Telerik MVC Grid and I am trying to get multiple clickable icons in one column. Did manage to do this via

columns.Command(command => {
                 command.Custom("View").Click("view").IconClass("k-icon k-i-preview k-i-eye");     

                 command.Custom("Modify").Click("modify").IconClass("k-icon k-i-track-changes"); });

What I really want to achieve is to do this not via command, but in a normal column, using own icon with "onclick" event.

Did try this, but does not really work.

columns.Template(@<text><span class='viewicon' onclick='view'><span class='modifyicon' onclick='modify'></text>)

When I tried : columns.Template(@<text><span class='viewicon' onclick='view'></text>), the event does not get attached to the icon.

Maybe you have some useful input on the topic. 

Thanks a lot!

6 Answers, 1 is accepted

Sort by
0
Irina
Top achievements
Rank 1
answered on 16 Sep 2019, 02:09 PM

Hi,

as I managed this and maybe someone also needs something similar, this is how I solved it:

columns.Bound(p => p.Action).ClientTemplate(
   "<span class='k-icon k-i-preview k-i-eye' title='View' onclick='view()'></span>" +
   "<span class='k-icon k-i-track-changes' title='Modify'  onclick='modify()'></span>" +
    "<span class='k-icon k-i-delete k-i-trash' title='Delete' onclick='delete()'></span>");
})
0
Ianko
Telerik team
answered on 17 Sep 2019, 07:13 AM

Hi Rina,

Using template is valid option for the required icons. You could also use the custom command options, but using HtmlAttributes method to add your own classes and achieve similar result.

Regards,
Ianko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Irina
Top achievements
Rank 1
answered on 17 Sep 2019, 07:31 AM
Thanks Ianko, good to know that this is achievable both ways.
0
Yih Wern
Top achievements
Rank 1
Veteran
answered on 07 Oct 2020, 07:39 PM

Hi Ianko,

Thanks for the information about the HtmlAttributes method.

I would hope that you could provide a live demo or code snippets of using HtmlAttributes to display clickable icons that will redirect to other Razor pages.

Thank you :)

0
Aleksandar
Telerik team
answered on 09 Oct 2020, 02:09 PM

Hello Yih Wern,

You can attach an onclick handler via the HtmlAttributes and then redirect to the required page:

columns.Command(command => {
                    command.Custom("Custom Command").IconClass("k-icon k-i-preview").HtmlAttributes(new {@onclick="myFunction(this)"});
                });

function myFunction(args) {
        var grid = $('#grid').getKendoGrid();
        var dataItem = grid.dataItem(args.closest('tr'));
        location.href = "@Url.Action("MyAction","MyController")" + dataItem.OrderID;
    }

Regards,
Aleksandar
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/.

0
Yih Wern
Top achievements
Rank 1
Veteran
answered on 09 Oct 2020, 03:40 PM

Hi Aleksandar,

Thank you very much for the excellent answer with the sample codes :)

Cheers

Yih Wern

Tags
Grid
Asked by
Irina
Top achievements
Rank 1
Answers by
Irina
Top achievements
Rank 1
Ianko
Telerik team
Yih Wern
Top achievements
Rank 1
Veteran
Aleksandar
Telerik team
Share this question
or