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

[Solved] Auto generated columns & template columns without using columns.Bound()

3 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
quentinjs
Top achievements
Rank 1
quentinjs asked on 15 Sep 2010, 03:45 PM
I would like to use the Grid(Model) aproach to auto generate  all the columns into the grid, BUT I would like to then ADD and Edit template link.  But if I do the template, I must manually do all the columns.Bound() for all the columns as well.  Is there a way to do this?

Something like this: 

<% Html.Telerik().Grid(Model)
       .Name("Orders")
       .Columns(columns =>
       {
          //Template column which shows an action link
          columns.Template(o => 
          {
              %>
                  <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID }) %>
              <%
          }).Title("Edit");
       })
       .Render();
%>

3 Answers, 1 is accepted

Sort by
0
quentinjs
Top achievements
Rank 1
answered on 26 Sep 2010, 08:44 PM
Help please! 
0
Atanas Korchev
Telerik team
answered on 27 Sep 2010, 07:41 AM
Hi quentinjs,

 This is currently not supported by Telerik Grid for ASP.NET MVC. If you have to add columns you have to declare them all through the fluent API.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
quentinjs
Top achievements
Rank 1
answered on 27 Sep 2010, 08:16 AM
I had a hunch that was the case.  I guess I'll have to add a function block to generate the fields auto-magically for me.  I hope an approach of...


% Html.Telerik().Grid(Model)
       .Name("Orders")
       .Columns(columns =>
       {
          //Template column which shows an action link
          columns.Template(o => 
          {
              %>
                  <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID }) %>
              <%
          }).Title("Edit");    
 <<< Look at the Model and create column text for all fields that are visible >>>
       })
       .Render();

I have to say that just because I want to add command buttons or action links I loose the autogenerate capability is not a good approach.  It should do the autogenerate and then anything else you add is added into that mix.  If you don't autogenerate then all you get are the ones you manually added.   That seems logical to me at 1am in the morning....
Tags
Grid
Asked by
quentinjs
Top achievements
Rank 1
Answers by
quentinjs
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or