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

templates

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 07 May 2013, 02:31 PM
i keep see in code examples, a template  like this
columns.Template(t => { }).HeaderTemplate("").ClientTemplate(@"
< a href='javascript: void(0)' class='abutton edit' onclick='editRow(this)' title='button edit'>button edit</a>
< a href='javascript: void(0)' class='abutton delete' onclick='deleteRow(this)' title='button delete'>button delete</a>")

if i have to give other parameters to that editRow javascript function or multiple,for example a string something like editRow(this,2,'text',g) can i do it ? and how do i format this in that template context?
from the above example some parameters are given by value,some by reference.


and if i write "this" ,always it is interpreted as the sender of that event?it's very insteresting,i write something as a text and it is interpreted as a valid value,in this case a reference.


Regards,
Daniel

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 09 May 2013, 02:29 PM
Hello Daniel,

Basically you to pass string you need to surround it with quotes, Since you need to alternate single with double quotes, the second level should be escaped. 

To see what I mean:

.ClientTemplate("<a href='javascript: void(0)' class='abutton edit' onclick='editRow(this,\"some string\")' title='button edit'>button edit</a>" +
"<a href='javascript: void(0)' class='abutton delete' onclick='deleteRow(this)' title='button delete'>button delete</a>");

The 'this' keyword is the sender - the <a> element from the example above:

http://stackoverflow.com/questions/6575210/how-to-pass-the-id-of-an-element-that-triggers-an-onclick-event-to-the-event-h


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Daniel
Top achievements
Rank 1
answered on 10 May 2013, 02:18 PM
ok,thank you for the informations.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or