public RoleViewModel(IDataAccessService dataService, RoleView view, Permissions appUserPermissions, Role role, List <Permission> appPermissions, List <Permission> rolePermissions, List <User> appUsers, List <User> roleUsers) : base() { this.view = view; this.das = dataService; this.title = "Редактирование группы \"" + role.Description + "\""; this.appUserPermissions = appUserPermissions; this.role = role; this.rolePermissions = DataTablesHelper.CreatePermissionsTable(); DataTablesHelper.FillPermissionsTable(this.rolePermissions, appPermissions, rolePermissions); this.roleUsers = DataTablesHelper.CreateUsersTable(); DataTablesHelper.FillRoleUsersTable(this.roleUsers, appUsers, roleUsers); this.roleUsers.ColumnChanging += RoleUsers_ColumnChanging; this.rolePermissions.ColumnChanged += RolePermissions_ColumnChanged; }
public IActionResult LoadData() { var currentUserId = User.Claims.ElementAt(0).Value; var sows = _sowService.GetAllSowsAsync(currentUserId).GetAwaiter().GetResult(); var dtModel = DataTablesHelper.BindRequestForm(Request.Form); var sowsFilter = DataTablesHelper.FilterData(ref dtModel, sows); return(Json(new { draw = dtModel.Draw, recordsFiltered = dtModel.RecordsTotal, recordsTotal = dtModel.RecordsTotal, data = sowsFilter })); }
public IActionResult Index() { var dataProviderUrl = Url.Action("DataTables"); var viewModel = DataTablesHelper.DataTableVm <JabatanOrmawaRow>("dataTable", dataProviderUrl); viewModel.ShowFilterInput = true; viewModel.PageLength = 10; vmod.DataTableConfigVm = viewModel; return(View(vmod)); }
public IActionResult DataTablesExample() { OrganisasiOrmawaVM vmod = new OrganisasiOrmawaVM(); var dataProviderUrl = Url.Action("DataTablesExampleDataProvider"); var viewModel = DataTablesHelper.DataTableVm <OrganisasiOrmawaRow>("dataTable", dataProviderUrl); viewModel.ShowFilterInput = true; viewModel.PageLength = 10; vmod.DataTableConfigVm = viewModel; return(View(vmod)); }
public IActionResult LoadTableData(DataTablesOrdersTableAjaxPost model) { var searchResult = DataTablesHelper.OrdersTable_Search(orderRepository, model, out int filteredResultsCount, out int totalResultsCount); return(Json(new { draw = model.Draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, data = searchResult })); }
public UserViewModel(IDataAccessService dataService, UserView view, ManageUserAction action, Permissions appUserPermissions, List <Role> appRoles, List <Permission> appPermissions, List <RolePermission> rolesPermissions, User user = null, List <Role> userRoles = null) : base() { this.view = view; this.das = dataService; this.action = action; this.appUserPermissions = appUserPermissions; if (action == ManageUserAction.Add) { this.title = "Создание пользователя"; } else if (action == ManageUserAction.Modify) { this.title = "Редактирование пользователя"; } if (user == null) { this.user = new User(); } else { this.user = user; this.oldUser = user.Clone(); this.user.PropertyChanged += User_PropertyChanged; } this.rolesPermissions = rolesPermissions; this.userRoles = DataTablesHelper.CreateRolesTable(); DataTablesHelper.FillUserRolesTable(this.userRoles, appRoles, userRoles); this.userPermissions = DataTablesHelper.CreatePermissionsTable(); DataTablesHelper.FillPermissionsTable(this.userPermissions, appPermissions); this.updateUserPermissions(); this.UserChanged = false; //this.userRoles.RowChanging += UserRoles_RowChanging; //this.userRoles.ColumnChanging += UserRoles_ColumnChanging; this.userRoles.ColumnChanged += UserRoles_ColumnChanged; }
public JsonResult GetFilteredContacts([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest dataTablesRequestModel) { int filteredCount; int totalCount; var sortedColumns = dataTablesRequestModel.Columns.GetSortedColumns(); var sortingConfig = DataTablesHelper.GetSortingConfig(sortedColumns); var searchConfig = DataTablesHelper.GetSearchingConfig(dataTablesRequestModel.Search.Value, dataTablesRequestModel.Columns); var filterConfig = new DataTablesFilteringModel { SearchConfig = searchConfig, SortingConfig = sortingConfig, StartIndex = dataTablesRequestModel.Start, ItemAmount = dataTablesRequestModel.Length, }; var filteredResults = _unitOfWork.PersonRepository.GetFilteredList(filterConfig, out filteredCount, out totalCount); var data = filteredResults.Select(contact => new ContactListItemViewModel { Id = contact.Id, Name = contact.Name, Surname = contact.Surname, Emails = contact.Emails .Select(email => new EmailViewModel { Id = email.Id, Name = email.Name, PersonId = email.PersonId }), Addresses = contact.Addresses .Select(address => new AddressViewModel { Id = address.Id, Name = address.Name, PersonId = address.PersonId }) }); return(Json(new DataTablesResponse ( dataTablesRequestModel.Draw, data, filteredCount, totalCount ), JsonRequestBehavior.AllowGet)); }
protected virtual DataTableConfigVm ConfigureDataTable() { var getDataUrl = Url.Action(nameof(this.GetTableData)); var vm = DataTablesHelper.DataTableVm <T>(BuildTableID(), getDataUrl); vm.Filter = true; vm.ShowFilterInput = true; vm.TableTools = false; vm.LengthMenu = LengthMenuVm.Default(); vm.PageLength = 10; vm.ColVis = false; return(vm); }
public async Task <IActionResult> GetProducts([FromBody] DtParameters dtParameters, int categoryId) { var orderString = DataTablesHelper.GetOrderStringFromDtParams(nameof(ProductViewModel.Id), dtParameters, new Dictionary <string, string>() { { nameof(ProductViewModel.Id), nameof(ProductViewModel.Id) } }); int totalCount = 0; var products = _productService.GetProducts(categoryId, Constants.PageSize, dtParameters.Start, orderString, out totalCount); var productsViewModelList = new List <ProductViewModel>(); products.ForEach(p => { var viewModel = mapper.Map <Product, ProductViewModel>(p); viewModel.CategoryNameEn = p.Category.NameEn; viewModel.CategoryNameAr = p.Category.NameAr; productsViewModelList.Add(viewModel); }); var data = new DataTablesResponseViewModel(dtParameters.Draw, productsViewModelList, totalCount, totalCount); return(Json(data)); }
public ActionResult Index() { var getDataUrl = Url.Action(nameof(HomeController.GetUsers)); var vm = DataTablesHelper.DataTableVm <UserTableRowViewModel>("idForTableElement", getDataUrl); //but you can also set them in a typed fashion: vm.Filter = true; //Enable filtering vm.ShowFilterInput = true; //Show or hide the search-across-all-columns input //Use the advanced per-column filter plugin vm.UseColumnFilterPlugin = true; vm //Fluently configure, or use attributes on the ViewModel .FilterOn("Position", new { sSelector = "#custom-filter-placeholder-position" }, new { sSearch = "Tester" }).Select("Engineer", "Tester", "Manager") .FilterOn("Id").NumberRange() .FilterOn("Salary", new { sSelector = "#custom-filter-placeholder-salary" }).NumberRange(); //You can set options on the datatable in an untyped way: // vm.JsOptions.Add("iDisplayLength", 25); // vm.JsOptions.Add("aLengthMenu", new object[] { new[] {5, 10, 25, 250, -1} , new object[] { 5, 10, 25, 250, "All"} }); vm.JsOptions.Add("fnCreatedRow", new Raw(@"function( nRow, aData, iDataIndex ) { $(nRow).attr('data-id', aData[0]); }")); //Enable localstorage based saving filter/sort/paging state vm.StateSave = true; //you can change the page length options... vm.LengthMenu = LengthMenuVm.Default(); // 5,10,25,50,All vm.LengthMenu.RemoveAll(t => t.Item2 == 5); //Take out 5 vm.PageLength = 25; //... and set a default //Enable column visibility vm.ColVis = true; vm.ShowVisibleColumnPicker = true; //Displays a control for showing/hiding columns //Localizable if (Request.QueryString["lang"] == "de") { //vm.Language = "{ 'sUrl': '" + Url.Content("~/Content/jquery.dataTables.lang.de-DE.txt") + "' }"; vm.Language = new Language { sProcessing = "Bitte warten...", sLengthMenu = "_MENU_ Einträge anzeigen", sZeroRecords = "Keine Einträge vorhanden.", sInfo = "_START_ bis _END_ von _TOTAL_ Einträgen", sInfoEmpty = "0 bis 0 von 0 Einträgen", sInfoFiltered = "(gefiltert von _MAX_ Einträgen)", sInfoPostFix = "", sSearch = "Suchen", sUrl = "", oPaginate = new Paginate() { sFirst = "Erster", sPrevious = "Zurück", sNext = "Weiter", sLast = "Letzter" } }.ToJsonString(); } return(View(vm)); }