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

Grid Template & Escape

1 Answer 275 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Lei
Top achievements
Rank 1
Lei asked on 18 Jul 2014, 07:16 PM
 
  Hi Guys

     Maybe this would seems a kind of silly question, but it really bothers these days, the problem is that

     I use the kendo MVVM to databind the viewmodel to the grid control. i use the template to display to content.
 
      ViewModel name is 'DetailModel', kendo grid control name is 'DetailGrid'
 
      the template is "<span title='" + FieldName + "'> #: " + (FieldName == null) ? ' ' : FieldName + "# </span>"    which FieldName is a Viewmodel field name dynamically get from server after a post request to the server. for simplicity, I omit the code for post request.

     It works fine when the FieldName is 'normal' character (alphanumeric, 'FirstName', 'LastName' etc), but it fails when the FieldName contains '&', for example 'Family&WoldTeam'. I
 
    The scenario is kind of the same in  http://jsfiddle.net/cJmE2/315/ link with  'firstDate' field name changes to 'first&Date' .

    Is there a work around for this problem ? i don't think that we can escape that '&' character or html encode in the field name with '&&' or '&amp;'

   I would greatly appreciate if you can come up with some suggestion or solution .


                                                                                                                                                   Thanks & Regards 

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 22 Jul 2014, 10:19 AM
Hello Lei,

You can use the model field from definition to turn the field name into something that the grid recognizes.

options.fields.fieldName.from String
 
Specifies the field of the original record which value to be used for population of the Model field.

Note that this option is not supported in recent kendo versions - your jsfiddle uses a version which is more than 2 years old. 


Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Lei
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or