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

[Solved] Too much code in Views

3 Answers 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alfred C
Top achievements
Rank 1
Alfred C asked on 21 Jan 2010, 08:39 PM
The new MVC controls make liberal use of extensions, lambda expressions, and daisy chaining to render a control.  This results in a complex piece of code in an otherwise clean view.

Has any thought been given to separating configuration from the rendering of the controls?  Possibly with a separate configuration object that encapsulates control specific attributes and data mappings, either with an inheritable class for which to construct a strongly typed View-Model or something to pass to the telerik controls that maps ViewDataDictionary keys to telerik attributes?

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 Jan 2010, 08:20 AM
Hi Alfred C,

The way I see it all the code in the view for a UI component is configuration. No part of the rendering is included (apart from the occasional Render() method which is necessary only when using templates). Could you please elaborate? A few examples will be of help.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jeremy Shantz
Top achievements
Rank 1
answered on 25 Jan 2010, 02:05 AM
Suppose you wanted a grid on a single "Category" view page to display different columns depending on the category ID.  I'm not sure how you'd do that except by doing a switch on category ID and creating the grid for each value. I'd like to pass in the column and formatting config into the page via the model. Something like this:

                Html.Telerik().Grid<DomainModel.tickets>(Model.GridData.Data)    
                    .Name("Grid")
                    .ServerBinding(serverBinding => serverBinding.Action(action, controller, new { categoryID = Model.Model.CatID}))
                    .Scrollable(scrolling => scrolling.Enabled(false))
                    .Pageable(paging => paging.Enabled(true).PageSize(3000))
                    .Columns(Model.Columns)
                    .Render()
0
Atanas Korchev
Telerik team
answered on 25 Jan 2010, 08:42 AM
Hi Jeremy Shantz,

Thank you for the clarification. I now see what you mean. Indeed it is not easy right now to dynamically configure grid columns mostly because a bound column requires a lambda expression which is not trivial to make without the help of the C# compiler. What you are suggesting is indeed looks like a better approach.
I have logged this as a feature suggestion and people can vote for it. If it is well accepted we will implemented in a future release.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Alfred C
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jeremy Shantz
Top achievements
Rank 1
Share this question
or