Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model IEnumerable<SAReds.UI.Web.Models.DepartmentModel>
- @(Html.Telerik().Grid<SAReds.UI.Web.Models.DepartmentModel>(Model)
- .Name("Grid")
- .DataKeys(keys =>
- {
- keys.Add(o => o.Id);
- })
- .Columns(columns =>
- {
- columns.Bound(o => o.CompanyName).Title("Company Name").Width(150);
- columns.Bound(o => o.Name).Title("Department Name").Width(150);
- columns.Bound(o => o.Active).Width(100).Title("Active");
- columns.Template(o => Html.ActionLink("Edit", "EditDepartment", new { o.Id })).Width(35)
- .ClientTemplate("<a href=" " + Url.Action("EditDepartment", "Task") + "/<#= Id#>">Edit</a>")
- .Title("Edit");
- })
- .DataBinding(dataBinding =>
- {
- dataBinding.Server().Select("CompanyDepartment", "Task", new
- {
- ajax =
- ViewData["ajax"]
- });
- dataBinding.Ajax().Select("_CompanyDepartment",
- "Task").Enabled((bool)ViewData["ajax"]);
- })
- .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
- .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
- .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
- .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
- .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
- .Footer((bool)ViewData["showFooter"]) )
- public ActionResult CompanyDepartment(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,bool? grouping, bool? showFooter)
- {
- ViewData["ajax"] = ajax ?? true;
- ViewData["scrolling"] = scrolling ?? true;
- ViewData["paging"] = paging ?? true;
- ViewData["filtering"] = filtering ?? true;
- ViewData["grouping"] = grouping ?? true;
- ViewData["sorting"] = sorting ?? true;
- ViewData["showFooter"] = showFooter ?? true;
- IDataOperations ops = DataSession.GetDataOperations(null);
- List<Department> Depts = new List<Department>();
- List<Employee> employeeList = new List<Employee>();
- ops.Load(Depts).Select("*").From("Department");
- ops.Commit();
- //Employee employee = new Employee();
- Company company = new Company();
- ops.Load(employeeList);
- ops.Commit();
- List<DepartmentModel> deptModel = new List<DepartmentModel>();
- foreach(Department dp in Depts)
- {
- ops.Load(company).FilterColumns("Id").Values(new { Id = dp.CompanyId });
- ops.Commit();
- deptModel.Add(new DepartmentModel()
- {
- Id = dp.Id,
- CompanyId = dp.CompanyId,
- Active = dp.Active,
- Name = dp.Name,
- CompanyName = company.Name
- });
- }
- return View(deptModel);
- }
- [GridAction]
- public ActionResult _CompanyDepartment()
- {
- IDataOperations ops = DataSession.GetDataOperations(null);
- List<Department> Depts = new List<Department>();
- ops.Load(Depts).Select("*").From("Department");
- List<DepartmentModel> deptModel = new List<DepartmentModel>();
- foreach (Department dp in Depts)
- {
- deptModel.Add(new DepartmentModel()
- {
- Id = dp.Id,
- CompanyId = dp.CompanyId,
- Active = dp.Active,
- Name = dp.Name
- });
- }
- return View(new GridModel<<SAReds.UI.Web.Models.DepartmentModel>>
- {
- Data = deptModel
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement