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

Column Template in Grid using MVVM

4 Answers 386 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 11 Aug 2014, 08:04 PM
I am trying to define column template for the grid using MVVM. Below is the piece of code that i am using.

data-columns="[
                                    {'template':'<input type=checkbox ><\/input>'}
]"

This is working fine. But this html is not exactly valid as I am missing single quotes (') and I am using closing tag for input which is ideally not required. How can define this in correct way? I think i am missing something very simple.

4 Answers, 1 is accepted

Sort by
0
Raja
Top achievements
Rank 1
answered on 11 Aug 2014, 09:46 PM
Please ignore my previous post. This one works fine in IE 11 and Chrome but it gives an error in Visual Studio which I think is expected.
So no worry on this. Hope this has no problem with other versions/browsers.

data-columns="[
       {'template':'<input type=\'checkbox\' / >'}
]"

0
Accepted
Alexander Valchev
Telerik team
answered on 13 Aug 2014, 11:47 AM
Hello Raja,

Your solution is correct - the inner quotation marks should be escaped with a backslash.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mark
Top achievements
Rank 1
answered on 14 Sep 2015, 04:33 PM
How would I pass data to the template column?  I would want to build a link or command template column that builds a link to an edit or details page so I need to pass the Id to the Link/Template...Thanks...
0
Konstantin Dikov
Telerik team
answered on 16 Sep 2015, 10:06 AM
Hi Mark,

You can access the fields from the data item within a template by following the approach from the below help article:
As you will notice, you can use template like the following one for creating a link:
{'template':'<a href=\'pageurl?id=#=ProductID#\'\>link</a>'}

For your convenience, here is a dojo example with such implementation:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Raja
Top achievements
Rank 1
Answers by
Raja
Top achievements
Rank 1
Alexander Valchev
Telerik team
Mark
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or