Split data by delimiter and format hyperlink

1 Answer 97 Views
Grid Templates
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Benjamin asked on 25 Jul 2022, 01:13 PM

{name: “coy a, coy b, coy c”, id:”1,2,3”}

expected result in kendo grid


<a href=“/company/detail/1”>coy a</a>, <a href=“/company/detail/2”>coy b</a>,

<a href=“/company/detail/3”>coy c</a>


1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 28 Jul 2022, 08:18 AM

Hello Benjamin,

You can use columns.template function to split the name string and pass it to the <a> elements. For example:

{ field: "name", template: linksTemp },
...
  function linksTemp(dataitem) {
    var names = dataitem.name.split(",");
    var string = "<a href=“/company/detail/1”>" + names[0] + "</a></br>" + "<a href=“/company/detail/1”>" + names[1] + "</a></br>" + "<a href=“/company/detail/1”>" + names[2] + "</a>"
    return string;
  }

Dojo example: https://dojo.telerik.com/upOnaWoM

Let me know if you have any questions.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid Templates
Asked by
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Nikolay
Telerik team
Share this question
or