detail template bind to dynamic data

3 posts, 0 answers
  1. Ziming
    Ziming avatar
    9 posts
    Member since:
    Mar 2015

    Posted 29 Mar 2015 Link to this post

    I am using kendo grid with detail template, when the detail template binds to the existing grid row, everything works fine. Now I try to use javascript to add dynamic data and bind to the template, I receive javascript error "Email is not defined". It looks like the template's context is set to the current grid, how can i change it to bind to dynamic data, below is my code

        .Columns(columns =>
            columns.Bound(p => p.ID).Title("ID");
            columns.Bound(p => p.Name).Title("Name");
            columns.Bound(p => p.Telephone).Title("Telephone");
            columns.Bound(p => p.Extension).Title("Extension");
            columns.Bound(p => p.Group).Title("Group");

        .HtmlAttributes(new { style = "height: 430px;" })
        .Pageable(pageable => pageable.Refresh(true).PageSizes(true).ButtonCount(5))
        .DataSource(dataSource => dataSource
        .Events(events => events.DetailExpand("onDetailExpand"))


    <script id="template1" type="text/html">
        <div class='employee-details'>
            Contact Details:
                <li><label>Name:</label>#= Name #</li>
                <li><label>Mobile:</label>#= Telephone #</li>
                <li><label>E-mail Address:</label>#= Email #</li>

        function dataBound() {
        function onDetailExpand() {
            var javascriptTemplate = kendo.template($("#template1").html());
            var javascriptData = {FirstName: "Ziming", Telephone: "12345678", Email: ""};
  2. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 01 Apr 2015 Link to this post

    Hello Ziming,

    The template will be automatically bound with the data item from the Grid. That said the grid item should have all three fields from the template - Name, Email, Telephone, otherwise the error will be triggered.

    Nikolay Rusev

    See What's Next in App Development. Register for TelerikNEXT.

  3. Ziming
    Ziming avatar
    9 posts
    Member since:
    Mar 2015

    Posted 01 Apr 2015 in reply to Nikolay Rusev Link to this post

    Thank you for your reply Nikolay, I use jQuery to populate the ul and it works fine :)
Back to Top