本文整理汇总了C#中GridViewModel类的典型用法代码示例。如果您正苦于以下问题:C# GridViewModel类的具体用法?C# GridViewModel怎么用?C# GridViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridViewModel类属于命名空间,在下文中一共展示了GridViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMaterialAreaPage
// GET: QLMaterialArea
public ActionResult GetMaterialAreaPage(int? index, int page, int pageSize)
{
GridViewModel<MaterialArea> viewModel = new GridViewModel<MaterialArea>();
int totalItems = dbContext.MaterialAreas.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<MaterialArea> data = dbContext.MaterialAreas.OrderBy(x => x.Name).Skip((page - 1) * pageSize).Take(pageSize).ToList();
//foreach (var item in data)
//{
// if (item.MenuItem.MenuItems != null)
// {
// item.MenuItem.MenuItems = null;
// }
//}
if (index != null)
{
viewModel = new GridViewModel<MaterialArea> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<MaterialArea> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例2: Index
public virtual ActionResult Index()
{
IList<GridColumnViewModel> columns = new List<GridColumnViewModel>
{
new GridColumnViewModel {Name = Translate(".Model.UserGroup.Name"), Index = "Name"},
new GridColumnViewModel
{
Name = Translate(".Model.UserGroup.RolesList"),
Width = 150,
Sortable = false
},
new GridColumnViewModel
{
Name = Translate(".Model.UserGroup.UsersList"),
Sortable = false
},
new GridColumnViewModel
{
Width = 10,
Sortable = false
},
new GridColumnViewModel
{Name = "Id", Sortable = false, Hidden = true}
};
var model = new GridViewModel
{
DataUrl = Url.Action(MVC.Admin.UserGroup.DynamicGridData()),
DetailsUrl = String.Format("{0}/", Url.Action(MVC.Admin.UserGroup.Edit())),
DefaultOrderColumn = "Name",
GridTitle = ".UserGroups",
Columns = columns
};
return View(model);
}
示例3: GetSubCatagoryPage
public ActionResult GetSubCatagoryPage(int? index, int page, int pageSize)
{
GridViewModel<SubCatagorySolution> viewModel = new GridViewModel<SubCatagorySolution>();
int totalItems = dbContext.SubCatagorySolutions.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<SubCatagorySolution> data = dbContext.SubCatagorySolutions.Include(x => x.CatagorySolution).OrderBy(x => x.SubCatagorySolutionName).Skip((page - 1) * pageSize).Take(pageSize).ToList();
foreach (var item in data)
{
if (item.CatagorySolution.SubCatagorySolutions != null)
{
item.CatagorySolution.SubCatagorySolutions = null;
}
}
if (index != null)
{
viewModel = new GridViewModel<SubCatagorySolution> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<SubCatagorySolution> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例4: Index
public virtual ActionResult Index()
{
IList<GridColumnViewModel> columns = new List<GridColumnViewModel>
{
new GridColumnViewModel
{
Name = Translate(".Model.Widget.Title"), Index = "Title"
},
new GridColumnViewModel
{
Name = Translate(".Model.Widget.Module"), Sortable = false
},
new GridColumnViewModel
{
Name = Translate(".Model.Widget.Status"), Index = "widget.Status"
},
new GridColumnViewModel
{
Name = Translate("Actions.Actions"), Sortable = false
}
,
new GridColumnViewModel
{
Name = Translate("Actions.Edit"), Sortable = false
}
};
var model = new GridViewModel
{
DataUrl = Url.Action(MVC.Admin.Widget.DynamicGridData()),
DefaultOrderColumn = "Id",
GridTitle = Translate(".Widgets"),
Columns = columns
};
return View(model);
}
示例5: GetAccountByPage
// GET: QLNews
public ActionResult GetAccountByPage(int? index, int page, int pageSize)
{
var roleManager = new RoleManager<Microsoft.AspNet.Identity.EntityFramework.IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
var idAdminRole = roleManager.FindByName("Admin").Id;
ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
GridViewModel<ApplicationUser> viewModel = new GridViewModel<ApplicationUser>();
int totalItems = userManager.Users.Where(x => x.Roles.Where(o => o.RoleId == idAdminRole).ToList().Count == 0).Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<ApplicationUser> data = userManager.Users.Where(x => x.Roles.Where(o => o.RoleId == idAdminRole).ToList().Count == 0).OrderBy(x => x.UserName).Skip((page - 1) * pageSize).Take(pageSize).ToList();
if (index != null)
{
viewModel = new GridViewModel<ApplicationUser> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<ApplicationUser> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例6: OnInitialized
protected override void OnInitialized()
{
GridViewModel = GetViewModel<GridViewModel<ListItemModel>>();
for (int i = 0; i < 20; i++)
{
GridViewModel.ItemsSource.Add(new ListItemModel { IsValid = true });
GridViewModel.ItemsSource.Add(new ListItemModel { IsValid = false });
}
}
示例7: FilterTemplatesFor
public HtmlTag FilterTemplatesFor(GridViewModel model)
{
var tag = new HtmlTag("div");
var containerNameForGrid = model.GridType.ContainerNameForGrid();
tag.Id("filters_" + containerNameForGrid);
tag.AddClass("smart-grid-filter");
tag.Append(new TableTag());
var metadata = new Dictionary<string, object>{
{"gridId", "grid_" + model.GridName},
{"initialCriteria", model.InitialCriteria()}
};
tag.MetaData("filters", metadata);
var properties = model.FilteredProperties;
var templates = _sources.Distinct().SelectMany(x => x.TagsFor(properties));
var operators = properties.Select(prop =>
{
return new SelectTag(select =>
{
prop.Operators.Each(oper => select.Option(oper.ToString(), oper.Key));
}).AddClass(prop.Accessor.Name);
});
tag.Add("div", div =>
{
div.Hide();
div.AddClass("templates");
div.Add("div").AddClass("smart-grid-editors").Append(templates);
div.Add("div").AddClass("smart-grid-operators").Append(operators);
div.Append(new SelectTag(select =>
{
select.AddClass("smart-grid-properties");
properties.Each(prop => select.Option(prop.Header, prop.Accessor.Name));
}));
});
return tag;
}
示例8: GetMenuPage
// GET: QLMenuItem
public ActionResult GetMenuPage(int? index, int page, int pageSize)
{
GridViewModel<MenuItem> viewModel = new GridViewModel<MenuItem>();
int totalItems = dbContext.MenuItems.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<MenuItem> data = dbContext.MenuItems.OrderBy(x => x.Name).Skip((page - 1) * pageSize).Take(pageSize).Include(x => x.ParentMenu).ToList();
foreach (var item in data)
{
if (item.MenuItems != null)
{
foreach (var i in item.MenuItems)
{
if (i.ParentMenu != null) {
i.ParentMenu.MenuItems = null;
}
}
}
if (item.ParentMenu != null)
{
item.ParentMenu.MenuItems = null;
item.ParentMenu.ParentMenu = null;
}
}
if (index != null)
{
viewModel = new GridViewModel<MenuItem> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<MenuItem> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例9: GetLinkHeaderPage
// GET: QLLinkHeader
public ActionResult GetLinkHeaderPage(int? index, int page, int pageSize)
{
GridViewModel<LinkHeader> viewModel = new GridViewModel<LinkHeader>();
int totalItems = dbContext.LinkHeaders.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<LinkHeader> data = dbContext.LinkHeaders.Where(x => x.Type == TypeLink.Link).OrderBy(y => y.Id).Skip((page - 1) * pageSize).Take(pageSize).ToList();
if (index != null)
{
viewModel = new GridViewModel<LinkHeader> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<LinkHeader> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例10: GetSlideShowPage
public ActionResult GetSlideShowPage(int? index, int page, int pageSize)
{
GridViewModel<SlideShow> viewModel = new GridViewModel<SlideShow>();
int totalItems = dbContext.SlideShows.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<SlideShow> data = dbContext.SlideShows.OrderBy(x => x.Name).Skip((page - 1) * pageSize).Take(pageSize).ToList();
if (index != null)
{
viewModel = new GridViewModel<SlideShow> { GridData = data, CurrentPage = page, TotalItems = totalItems };
}
else
{
viewModel = new GridViewModel<SlideShow> { GridData = data, TotalItems = totalItems };
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例11: GetAllNews
// GET: QLNews
public ActionResult GetAllNews(int? index, int page, int pageSize)
{
GridViewModel<News> viewModel = new GridViewModel<News>();
int totalItems = dbContext.Newss.Count();
if (index != null && index != 0)
{
page = (int)Math.Ceiling((decimal)(index + 1) / (decimal)pageSize);
}
if (index == 0)
{
page = 1;
}
IEnumerable<News> data = dbContext.Newss.Include(x => x.CatagoryNews).OrderBy(x => x.Date).Skip((page - 1) * pageSize).Take(pageSize).ToList();
if (index != null)
{
viewModel = new GridViewModel<News> { GridData = data, CurrentPage = page, TotalItems = totalItems};
}
else
{
viewModel = new GridViewModel<News> { GridData = data, TotalItems = totalItems};
}
return Json(viewModel, JsonRequestBehavior.AllowGet);
}
示例12: CreateGridViewModel
static GridViewModel CreateGridViewModel()
{
var viewModel = new GridViewModel();
viewModel.KeyFieldName = "Id";
viewModel.Columns.Add("GraphicName");
viewModel.Columns.Add("GraphicType");
viewModel.Pager.PageSize = 10;
return viewModel;
}
示例13: CreateGridViewModel
static GridViewModel CreateGridViewModel()
{
var viewModel = new GridViewModel();
viewModel.KeyFieldName = "Id";
viewModel.Columns.Add("Name");
viewModel.Columns.Add("Capacity");
viewModel.Columns.Add("Type");
viewModel.Columns.Add("Measurement");
viewModel.Pager.PageSize = 10;
return viewModel;
}
示例14: UserGroups
public virtual ActionResult UserGroups(long id)
{
var role = roleService.Find(id);
if (role == null)
{
throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
}
IList<GridColumnViewModel> columns = new List<GridColumnViewModel>
{
new GridColumnViewModel
{
Name = Translate(".Model.Role.UserGroupName"),
Index = "Name",
Width = 1100
},
new GridColumnViewModel
{
Name = "Id",
Sortable = false,
Hidden = true
}
};
var model = new GridViewModel
{
DataUrl = Url.Action(MVC.Admin.Role.UserGroupsDynamicGridData()),
DefaultOrderColumn = "Name",
GridTitle = Translate(".Model.UserGroups"),
Columns = columns,
MultiSelect = true,
IsRowNotClickable = true,
SelectedIds = role.UserGroups.Select(t => t.Id),
Title = String.Format(Translate("Titles.Role_UserGroups"), role.Name)
};
return View(model);
}
示例15: ItemsSourceShouldBeEmptyWhenVmCreated
public void ItemsSourceShouldBeEmptyWhenVmCreated()
{
var gridViewModel = new GridViewModel<object>();
gridViewModel.ItemsSource.ShouldBeEmpty();
}