Custom template or html helper column binding in the grid

3 posts, 0 answers
  1. Balwant
    Balwant avatar
    4 posts
    Member since:
    Oct 2012

    Posted 14 Mar 2013 Link to this post

    Hello,

    I need some help to complete below functionality.

    I am trying to bind/create a template column, so when the grid loads it can call an html helper or controller action to get the value/text for that column. Which means, i am trying to bind a non modal or datasource property  to one of the grid columns.

    Goal: Bind one of the columns in kendo grid with external text.

    My grid looks something like this,

     @(Html.Kendo().Grid<Model>()
              .Name("Grid")
              .AutoBind(false)
              .Columns(columns =>
                  {
                      columns.Bound(row => row.Id).Hidden(true);
                      columns.Bound(row => row.Name);

                     columns.Template(@<text>@Html.GetSomeText("SomeContext")</text>).Title("title");

                     columns.Template(@<text>@Html.Action("GetSomeText", "controller", new {ctx = SomeContext})</text>);
                   }

    As you can see above, I tried couple of ways to get the text for the column - Html helper and Action Method, but in both the cases, server side code is not even being triggerd and column remains empty in the grid.

    Any help is much appreciated.

    Thanks,
    Balwant
  2. Balwant
    Balwant avatar
    4 posts
    Member since:
    Oct 2012

    Posted 15 Mar 2013 Link to this post

    Has anyone got a chance to look at it?

    It would be nice to know the solution, so we can fix any similar issues we had earlier or updates in future.

    Thanks,
    Balwant
  3. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 18 Mar 2013 Link to this post

    Hello Balwant,

    I assume that your Grid is configured to use Ajax binding. If so please notice that to create template column you need to set the ClientTemplate of the column. 

    Also ClienTemplate could not contain any C# logic / helpers - you should pass a string which is evaluated on the client side (in the browser) with JavaScript. 

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top