Accessing fields in a grid column using C#

2 posts, 1 answers
  1. Reid
    Reid avatar
    431 posts
    Member since:
    Oct 2008

    Posted 23 Jan 2017 Link to this post

    Is it possible to access the data of a column/field in a template like a row template in a razor template?
    for instance : <li><label>Parent Test :</label>&nbsp; <strong>#= ParentTest #</strong></li>   

    @{

        // How would I get the value of this var?

       var parentTest = ?

    }

     

    Thanks

     

  2. Answer
    Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1047 posts

    Posted 25 Jan 2017 Link to this post

    Hello Reid,

    I am not sure I fully understand the question, but it is not possible to access a value created, and evaluated on the client, in the server-side code. You can pass C# variables to the template, e.g.:

    //.cshtml file
     
    @{
        var test = "...";
    }
     
    ...
        .ClientRowTemplate(
            "<tr data-uid='#: uid #'>" +
               ...
                "<td class='details'>" +
                    "<span class='title'>#: Title # " + @test + "</span>" +...

    ... but not the other way around.

    Further information about Kendo UI templates is available in the following section of our documentation:

    http://docs.telerik.com/kendo-ui/framework/templates/overview

    You can also inspect the Grid row template online demo (also available in the offline demos application).

    I hope this helps.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top