-
Notifications
You must be signed in to change notification settings - Fork 0
/
_GridViewPartial.cshtml
90 lines (86 loc) · 4.43 KB
/
_GridViewPartial.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@{
var grid = Html.DevExpress().GridView(settings => {
settings.Name = "GridView";
settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Home", Action = "GridViewPartialAddNew" };
settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Home", Action = "GridViewPartialUpdate" };
settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "GridViewPartialDelete" };
settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
settings.SettingsBehavior.ConfirmDelete = true;
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowDeleteButton = true;
settings.CommandColumn.ShowEditButton = true;
settings.KeyFieldName = "ModelID";
settings.SetEditFormTemplateContent(c => {
var editItem = ViewData["Item"] != null ? ViewData["Item"] : c.DataItem;
Html.DevExpress().FormLayout(set => {
set.Name = "FormLayout";
set.Items.AddGroupItem(groupSettings => {
groupSettings.Caption = "ModelGroup";
groupSettings.Name = "group";
groupSettings.Items.Add(item => {
item.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox;
item.Name = item.Caption = "Name";
item.SetNestedContent(() => {
Html.DevExpress().TextBox(tb => {
tb.Name = "ModelName";
tb.ShowModelErrors = true;
}).Bind(DataBinder.Eval(editItem, "ModelName")).Render();
});
});
groupSettings.Items.Add(item => {
item.NestedExtensionType = FormLayoutNestedExtensionItemType.DateEdit;
item.Name = item.Caption = "Date";
item.SetNestedContent(() => {
Html.DevExpress().DateEdit(tb => {
tb.Name = "ModelDate";
tb.ShowModelErrors = true;
}).Bind(DataBinder.Eval(editItem, "ModelDate")).Render();
});
});
groupSettings.Items.Add(item => {
item.NestedExtensionType = FormLayoutNestedExtensionItemType.CheckBox;
item.Name = item.Caption = "State";
item.SetNestedContent(() => {
Html.DevExpress().CheckBox(tb => {
tb.Name = "ModelState";
tb.ShowModelErrors = true;
}).Bind(DataBinder.Eval(editItem, "ModelState")).Render();
});
});
});
}).Render();
Html.DevExpress().Button(
btnSettings => {
btnSettings.Name = "btnUpdate";
btnSettings.UseSubmitBehavior = false;
btnSettings.Text = "Update";
btnSettings.ClientSideEvents.Click = "function(s, e){ GridView.UpdateEdit(); }";
}
)
.Render();
Html.DevExpress().Button(
btnSettings => {
btnSettings.Name = "btnCancel";
btnSettings.UseSubmitBehavior = false;
btnSettings.Text = "Cancel";
btnSettings.ClientSideEvents.Click = "function(s, e){ GridView.CancelEdit(); }";
}
)
.Render();
});
settings.SettingsPager.Visible = true;
settings.Settings.ShowGroupPanel = true;
settings.Settings.ShowFilterRow = true;
settings.SettingsBehavior.AllowSelectByRowClick = false;
settings.Columns.Add("ModelID");
settings.Columns.Add("ModelName");
settings.Columns.Add("ModelState");
settings.Columns.Add("ModelDate");
});
if (ViewData["EditError"] != null) {
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
@grid.Bind(Model).GetHtml()