Property name starts with a pound

5 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 23 Jul 2013 Link to this post

    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?
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 24 Jul 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 24 Jul 2013 Link to this post

    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!
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 24 Jul 2013 Link to this post

    Thanks so much for re-reading and updating the post :D

    I'll try this now
  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 25 Jul 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready