/
Employees.cshtml
49 lines (42 loc) · 2.13 KB
/
Employees.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
@model PagedData<Employee>
@{
ViewBag.Title = "Employees";
var grid = Html.CarrotWeb().CarrotWebGrid<Employee>(Model);
grid.PrettifyHeadings = true;
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });
grid.ConfigName(Html.NameFor(x => x));
}
@using (Html.BeginForm(null, null, FormMethod.Post, new { @id = "sortTable" })) {
@Html.AntiForgeryToken()
grid
.AddColumn(new CarrotGridTemplateColumn<Employee> {
HeaderText = "ID",
FormatTemplate = @<text> @Html.CarrotWeb().ActionImage("ViewEmployee", "Admin", new { @id = @item.EmployeeId, @area=ViewBag.WidgetAssemblyName }, "~/assets/admin/images/pencil.png", @item.EmployeeId.ToString(), null, null) </text>
})
.AddColumn(new CarrotGridTemplateColumn<Employee> {
HeaderText = "LN",
FormatTemplate = @<text> @grid.FormFieldFor(m => m.LastName, GridFormFieldType.TextBox, new { maxlength = "64", @class = "form-control" }) </text>
})
.AddColumn(new CarrotGridTemplateColumn<Employee> {
HeaderText = "FN",
FormatTemplate = @<text> @grid.FormFieldFor(m => m.FirstName, GridFormFieldType.TextBox, new { maxlength = "64", @class = "form-control" }) </text>
})
.AddColumn(new CarrotGridTemplateColumn<Employee> {
HeaderText = "Territory",
FormatTemplate = @<text>
@grid.CheckBoxListFor(m => m.EmployeeTerritories,
new MultiSelectList(ViewBag.TerritoryList, "TerritoryId", "TerritoryDescription", item.EmployeeTerritories.Select(x => x.TerritoryId).ToList()),
"Selected")
</text>
})
.AddColumn(x => x.LastName, new CarrotGridColumn { HeaderText = "Last Name", Sortable = true })
.AddColumn(x => x.FirstName, new CarrotGridColumn { HeaderText = "First Name", Sortable = true })
.AddColumn(x => x.Notes, new CarrotGridColumn { Sortable = true });
@grid.OutputHtmlBody()
<nav>
@{
@grid.OutputFooter()
}
</nav>
}