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

Custom template or html helper column binding in the grid

2 Answers 673 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Balwant
Top achievements
Rank 1
Balwant asked on 14 Mar 2013, 07:49 PM
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 Answers, 1 is accepted

Sort by
0
Balwant
Top achievements
Rank 1
answered on 15 Mar 2013, 01:14 PM
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
0
Petur Subev
Telerik team
answered on 18 Mar 2013, 08:01 AM
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!
Tags
Grid
Asked by
Balwant
Top achievements
Rank 1
Answers by
Balwant
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or