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

[Solved] How to include common Grid configuration in all your Views by using one single .cshtml file?

0 Answers 111 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.
Max
Top achievements
Rank 1
Max asked on 25 Jan 2012, 06:27 AM
Hi all,
I keep using the same code over and over on my Views but not sure how I could move this to one single file and re-use it.
I tried @Html.Partial("FileName.cshtml") but it did not work. Here is my code:
@model IEnumerable<Test.DataModel.Model1>
         
<div id = "gridReusableCode">
@{
    GridButtonType buttonType = GridButtonType.Image;
    GridEditMode gridEditMode = GridEditMode.InLine;
    GridPagerPosition pagerPosition = GridPagerPosition.Bottom;
    GridPagerStyles pagerStyles = GridPagerStyles.NextPreviousAndNumeric;
    GridSortMode gridSortMode = GridSortMode.SingleColumn;
...
}
</div>
 
@(Html.Telerik().Grid(Model)
        .Name("Grid1")
...etc...
The Grid depends on all these variables so I get a bunch of errors?
Any way to render this View by reusing the code above?

Thank you!
Tags
Grid
Asked by
Max
Top achievements
Rank 1
Share this question
or