Grid Template & Escape

2 posts, 0 answers
  1. Lei
    Lei avatar
    1 posts
    Member since:
    Jun 2014

    Posted 18 Jul 2014 Link to this post

      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 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 
  2. Petyo
    Petyo avatar
    2436 posts

    Posted 22 Jul 2014 Link to this post

    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. 

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top