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

Property name starts with a pound

4 Answers 109 Views
Templates
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 23 Jul 2013, 04:17 PM
Okay so I'm using JSON.Net to convert an xml feed into JSON so load into the list view

PROBLEM is that the text content is defined with pound symbols as the prefix...and I have no idea how to bind that in the listview template

var templateHtml = "<div class='twit'>\
                        <h1>#: title.#cdata-section #</h1>\
                    </div>";
 
var templateHtml = "<div class='twit'>\
                        <h1>#: title.\\#cdata-section #</h1>\
                    </div>";

Nothing seems to work right...

If I just to #: title # it works, but clearly just shows [object Object]

Should also note I can't convert it in the schema as I need it to be generic and just give me the objects as-is

Ideas?

4 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 24 Jul 2013, 07:23 AM
Hi Steve,

As you already know the hash sign is used as  part of the template engine in Kendo UI. You can escape the hash using double backslash('\\'). You can read more about this in this forum topic:

http://www.kendoui.com/forums/kendo-ui-web/grid/how-to-escape-hash-character-in-column-template.aspx
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kiril Nikolov
Telerik team
answered on 24 Jul 2013, 01:37 PM
Hi Steve,

First of all I would like to apologize for overlooking my answer in the previous email, so please accept my sincere apologies. 

In order to access the property name starting with a "#" you can use the square bracket notation:
 
var obj= { 'person' :{
              '#title': 'Mr.',
              '#firstName': 'John'
    }
console.log(obj.name['#title']); // will output "Mr."

In your caser as you are using Kendo UI Template, using just this will result in "Invalid Template error", this is why you will need to escape the hash using "\\" or:

template: "${person['\\#name']}",

For your convenience here is a jsBin example which demonstrates a possible implementation.

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 24 Jul 2013, 01:43 PM
Thanks so much for re-reading and updating the post :D

I'll try this now
0
Kiril Nikolov
Telerik team
answered on 25 Jul 2013, 07:35 AM
Hello Steve,

Did you have time to try this? Please update me if it is working or not and once again accept my apologies for the misunderstanding in my first email.
 
Regards,
Kiril Nikolov
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
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Kiril Nikolov
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or