or
01.
public static CustomGridFor<
TProperty
> KendoGrid<
TModel
, TProperty>(
02.
Expression<
Func
<TModel, IEnumerable<TProperty>>> expression,
03.
string defaultProperty,
04.
string createAction,
05.
string readAction,
06.
string updateAction,
07.
string controller,
08.
string errorHandler) where TProperty : class
09.
{
10.
var dataSource = expression.Compile().Invoke(htmlHelper.ViewData.Model);
11.
var gridColumnSettings = GridBuilderExtensions.CreateGridColumnSettings<
TProperty
>() as List<
GridColumnSettings
>;
12.
if (gridColumnSettings != null)
13.
{
14.
gridColumnSettings.Add(new GridCommandColumnSettings { Commands = { new GridEditActionCommand(), }, });
15.
}
16.
17.
var gridBuilder = new this.Grid(dataSource)
18.
.Name("GridName")
19.
.Columns(c => c.LoadSettings(gridColumnSettings))
20.
.DataSource(source => source
21.
.Ajax()
22.
.PageSize(50)
23.
.Model(model => model.Id(defaultProperty))
24.
.Destroy(d => d.Action(destroyAction, controller))
25.
.Read(r => r.Action(readAction, controller))
26.
.Update(u => u.Action(updateAction, controller))
27.
.Batch(true)
28.
.Events(e => e.Error(errorHandler)))
29.
.ToolBar(a => a.Create().Text("New"))
30.
.Editable(editable => editable.Mode(GridEditMode.InLine));
31.
32.
return gridBuilder;
33.
}
01.
...
02.
columns.Bound(p => p.Category).ClientTemplate("#=Category.CategoryName#").Width(160);
03.
...
04.
.Model(model =>
05.
{
06.
model.Id(p => p.ProductID);
07.
model.Field(p => p.ProductID).Editable(false);
08.
})
09.
...
1.
...
2.
.DataSource(source => source.Ajax()
3.
.Model(model =>
4.
{
5.
model.Id(p => p.ProductID);
6.
model.Field(p => p.ProductID).Editable(false);
7.
})
8.
...
1.
.Columns(c => c.LoadSettings(new IEnumerable<
GridColumnSettings
>()))
Hi,
I’m working with a Kendo Grid using MVC4 with Razor’s syntax.
I need to be able to customize column’s order and displaying option in order to save user’s preference.
To achieve that, I tried to use a tab of GridColumnSettings and load it in the View using the LoadSettings method of the columns property.
I have a few issues with that:
- Even if the column order can be set dynamically with this method, I don’t understand how to use ClientTemplate or Template attribute of the GridColumnSettings object.
- By using this loading system I have two Gird's options who don’t work anymore: line and column are not selectable and the groupable option seems to not work too.
Thanks for your help.