public void HtmlGrid_SetsPartialViewName() { String actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).PartialViewName; String expected = "MvcGrid/_Grid"; Assert.Equal(expected, actual); }
public void HtmlGrid_SetsGridQuery() { Object?expected = htmlGrid.Html.ViewContext.HttpContext.Request.QueryString; Object?actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid.Query; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeQuery() { Object expected = htmlGrid.Grid.Query = new QueryCollection(); Object actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid.Query; Assert.Same(expected, actual); }
public void HtmlGrid_SetsGrid() { IGrid <GridModel> actual = new HtmlGrid <GridModel>(null, grid).Grid; IGrid <GridModel> expected = grid; Assert.Same(expected, actual); }
public void HtmlGrid_SetsDefaultPartialViewName() { String actual = new HtmlGrid<GridModel>(null, grid).PartialViewName; String expected = "MvcGrid/_Grid"; Assert.Equal(expected, actual); }
public static HtmlGrid <T> Grid <T>(this IHtmlHelper helper, IEnumerable <T> items, IQueryCollection query, string viewName, IViewEngine viewEngine = null) { var newGrid = new SGrid <T>(items, query); var htmlGrid = new HtmlGrid <T>(helper, newGrid, viewName); return(htmlGrid); }
public static HtmlGrid <T> Grid <T>(this IHtmlHelper helper, SGrid <T> sourceGrid, IViewEngine viewEngine) { //wrap source grid: var htmlGrid = new HtmlGrid <T>(sourceGrid, helper.ViewContext, DefaultPartialViewName, viewEngine); return(htmlGrid); }
public async Task <HtmlGrid <UserListDetails> > GetUserLists(GridParam gridParam) { List <Task <UserListDetails> > tasksUserlists = new List <Task <UserListDetails> >(); var details = _userManagementRepository.GetUserLists(StoredProcedureName, gridParam); foreach (UserListDetails user in details) { tasksUserlists.Add(Task.Run(() => UserGridManagement(user))); } var results = await Task.WhenAll(tasksUserlists); var userList = results.ToList(); _log.Information("User details got as {0}", JsonConvert.SerializeObject(userList)); var userLists = new HtmlGrid <UserListDetails> { aaData = userList }; var firstDefault = userList.FirstOrDefault(); if (firstDefault != null) { userLists.iTotalDisplayRecords = Convert.ToInt32(firstDefault.FilterCount); userLists.iTotalRecords = Convert.ToInt32(firstDefault.FilterCount); } return(userLists); }
public void HtmlGrid_SetsGrid() { Object actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid; Object expected = htmlGrid.Grid; Assert.Same(expected, actual); }
public HtmlGrid <RoleLists> GetRoleLists(GridParam roleDetails) { List <RoleLists> roleLists = new List <RoleLists>(); var details = _roleManagementRepository.GetRoleLists(roleDetails, StoredProcedureName); foreach (RoleLists role in details) { var detail = new RoleLists() { Name = role.Name, FilterCount = role.FilterCount }; var roleId = _encryptionService.EncryptString(role.Id); StringBuilder actionDetails = new StringBuilder(); if (_roleExtension.HasPermission(PermissionValueLists.EditRole)) { actionDetails.Append("<a href='" + _configuration["ApplicationData:RootUrl"] + "/CoreSetup/Role/EditRole/" + roleId + "' class='btn btn-sm btn-link btn-round' title='Edit Role'><i class=\"fas fa-user-edit\"></i></a>"); } detail.Action = actionDetails.ToString(); roleLists.Add(detail); } _log.Information("role list get list response as {0}", JsonConvert.SerializeObject(roleLists)); var roleList = new HtmlGrid <RoleLists>(); roleList.aaData = roleLists; var firstDefault = roleLists.FirstOrDefault(); if (firstDefault != null) { roleList.iTotalDisplayRecords = Convert.ToInt32(firstDefault.FilterCount); roleList.iTotalRecords = Convert.ToInt32(firstDefault.FilterCount); } return(roleList); }
public void HtmlGrid_SetsHtml() { IHtmlHelper actual = new HtmlGrid <GridModel>(html, grid).Html; IHtmlHelper expected = html; Assert.Same(expected, actual); }
public static HtmlGrid <T> Grid <T>(this IHtmlHelper helper, IEnumerable <T> items, string viewName, IViewEngine viewEngine = null) { var newGrid = new SGrid <T>(items, helper.ViewContext.HttpContext.Request.Query); var htmlGrid = new HtmlGrid <T>(helper, newGrid, viewName); return(htmlGrid); }
public void HtmlGrid_SetsHtml() { HtmlHelper expected = HtmlHelperFactory.CreateHtmlHelper(); HtmlHelper actual = new HtmlGrid <GridModel>(expected, grid).Html; Assert.Same(expected, actual); }
public static HtmlGrid <T> Grid <T>(this IHtmlHelper helper, SGrid <T> sourceGrid, IViewEngine viewEngine = null) { //wrap source grid: var htmlGrid = new HtmlGrid <T>(helper, sourceGrid, DefaultPartialViewName); return(htmlGrid); }
public static HtmlGrid <T> Grid <T>(this IHtmlHelper helper, SGrid <T> sourceGrid, string viewName, IViewEngine viewEngine) { //wrap source grid: var htmlGrid = new HtmlGrid <T>(helper, sourceGrid, viewName); return(htmlGrid); }
public string GetGridDetails(GridDetails param) { var accountDetails = new GridParam { DisplayLength = param.length, DisplayStart = param.start, SortDir = param.order[0].dir, SortCol = param.order[0].column, Flag = "A", Search = param.search.value, UserName = StaticData.GetUser() }; var gridList = buss.GetGridList(accountDetails); foreach (var item in gridList) { item.Action = StaticData.GetActions(ControllerName, item.UniqueId, "", AddEditId); //item.CreatedDate = StaticData.DBToFrontDate(item.CreatedDate); } HtmlGrid <GroceriesCommon> companyGrid = new HtmlGrid <GroceriesCommon>(); var firstDefault = gridList.FirstOrDefault(); companyGrid.aaData = gridList; if (firstDefault != null) { companyGrid.iTotalDisplayRecords = Convert.ToInt32(firstDefault.FilterCount); companyGrid.iTotalRecords = Convert.ToInt32(firstDefault.FilterCount); } var result = JsonConvert.SerializeObject(companyGrid).ToString(); return(result); }
public void HtmlGrid_SetsHtml() { IHtmlHelper expected = Substitute.For <IHtmlHelper>(); IHtmlHelper actual = new HtmlGrid <GridModel>(expected, grid).Html; Assert.Same(expected, actual); }
public void HtmlGrid_SetsDefaultPartialViewName() { String actual = new HtmlGrid <GridModel>(null, grid).PartialViewName; String expected = "MvcGrid/_Grid"; Assert.Equal(expected, actual); }
public static HtmlGrid <T> Grid <T>(this HtmlHelper helper, Grid <T> sourceGrid, string viewName) where T : class { //wrap source grid: var htmlGrid = new HtmlGrid <T>(sourceGrid, helper.ViewContext, viewName); return(htmlGrid); }
public void HtmlGrid_DoesNotChangeExistingQuery() { IReadableStringCollection query = grid.Query = TestHelper.ParseQuery(""); Object actual = new HtmlGrid<GridModel>(html, grid).Grid.Query; Object expected = query; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeExistingHttpContext() { HttpContextBase httpContext = grid.HttpContext = HttpContextFactory.CreateHttpContextBase(); Object actual = new HtmlGrid<GridModel>(htmlHelper, grid).Grid.HttpContext; Object expected = httpContext; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeExistingQuery() { NameValueCollection query = grid.Query = new NameValueCollection(); Object actual = new HtmlGrid<GridModel>(htmlHelper, grid).Grid.Query; Object expected = query; Assert.Same(expected, actual); }
public HtmlGridTests() { htmlHelper = HtmlHelperFactory.CreateHtmlHelper("id=3&name=jim"); grid = new Grid<GridModel>(new GridModel[8]); htmlGrid = new HtmlGrid<GridModel>(htmlHelper, grid); grid.Columns.Add(model => model.Name); grid.Columns.Add(model => model.Sum); }
public void HtmlGrid_DoesNotChangeExistingHttpContext() { ViewContext viewContext = grid.ViewContext = new ViewContext(); Object actual = new HtmlGrid<GridModel>(html, grid).Grid.ViewContext; Object expected = viewContext; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeViewContext() { ViewContext viewContext = grid.ViewContext = new ViewContext(); Object actual = new HtmlGrid <GridModel>(html, grid).Grid.ViewContext; Object expected = viewContext; Assert.Same(expected, actual); }
public void HtmlGrid_SetsGridQuery() { grid.Query = null; IQueryCollection expected = html.ViewContext.HttpContext.Request.Query; IQueryCollection actual = new HtmlGrid <GridModel>(html, grid).Grid.Query; Assert.Same(expected, actual); }
public void HtmlGrid_SetsGridQuery() { grid.Query = null; IQueryCollection expected = html.ViewContext.HttpContext.Request.Query; IQueryCollection actual = new HtmlGrid<GridModel>(html, grid).Grid.Query; Assert.Same(expected, actual); }
public HtmlGridExtensionsTests() { HtmlHelper html = HtmlHelperFactory.CreateHtmlHelper("id=3&name=jim"); IGrid <GridModel> grid = new Grid <GridModel>(new GridModel[8]); htmlGrid = new HtmlGrid <GridModel>(html, grid); grid.Columns.Add(model => model.Name); grid.Columns.Add(model => model.Sum); }
public void HtmlGrid_SetsHttpContext() { grid.ViewContext = null; ViewContext actual = new HtmlGrid<GridModel>(html, grid).Grid.ViewContext; ViewContext expected = html.ViewContext; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeExistingQuery() { grid.Query = new NameValueCollection(); Object actual = new HtmlGrid <GridModel>(null, grid).Grid.Query; Object expected = grid.Query; Assert.AreSame(expected, actual); }
public void HtmlGrid_SetsHttpContext() { grid.HttpContext = null; HttpContextBase actual = new HtmlGrid<GridModel>(htmlHelper, grid).Grid.HttpContext; HttpContextBase expected = htmlHelper.ViewContext.HttpContext; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeExistingHttpContext() { HttpContextBase httpContext = grid.HttpContext = HttpContextFactory.CreateHttpContextBase(); Object actual = new HtmlGrid <GridModel>(htmlHelper, grid).Grid.HttpContext; Object expected = httpContext; Assert.Same(expected, actual); }
public void HtmlGrid_SetsHttpContext() { grid.HttpContext = null; HttpContextBase actual = new HtmlGrid <GridModel>(htmlHelper, grid).Grid.HttpContext; HttpContextBase expected = htmlHelper.ViewContext.HttpContext; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeExistingQuery() { NameValueCollection query = grid.Query = new NameValueCollection(); Object actual = new HtmlGrid <GridModel>(htmlHelper, grid).Grid.Query; Object expected = query; Assert.Same(expected, actual); }
public HtmlGridExtensionsTests() { IGrid <GridModel> grid = new Grid <GridModel>(new GridModel[8]); IHtmlHelper html = Substitute.For <IHtmlHelper>(); htmlGrid = new HtmlGrid <GridModel>(html, grid); grid.Columns.Add(model => model.Name); grid.Columns.Add(model => model.Sum); }
public void HtmlGrid_DoesNotChangeQuery() { IQueryCollection query = grid.Query = new QueryCollection(); Object actual = new HtmlGrid<GridModel>(html, grid).Grid.Query; Object expected = query; Assert.Same(expected, actual); }
public void HtmlGrid_DoesNotChangeQuery() { htmlGrid.Grid.ViewContext = null; Object expected = htmlGrid.Grid.Query; Object actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid.Query; Assert.Same(expected, actual); }
public HtmlGridTests() { htmlHelper = HtmlHelperFactory.CreateHtmlHelper("id=3&name=jim"); grid = new Grid <GridModel>(new GridModel[8]); htmlGrid = new HtmlGrid <GridModel>(htmlHelper, grid); grid.Columns.Add(model => model.Name); grid.Columns.Add(model => model.Sum); }
public void HtmlGrid_SetsViewContext() { htmlGrid.Grid.ViewContext = null; Object expected = htmlGrid.Html.ViewContext; Object actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid.ViewContext; Assert.Same(expected, actual); }
HtmlGrid<SalesByVendor> BuildSalesByVendorGrid(List<SalesByVendor> sbv, string mailTarget=null){ HtmlGrid<SalesByVendor> g = new HtmlGrid<SalesByVendor>(); g.DataSource= sbv; if(! mailTarget.IsNullOrEmpty()) g.GridStyle= new GreyGridStyle(); // css = Inline Style else g.Css = new CayitaGridGrey(); // css = Style Sheet g.Title= "Sales by Vendor"; g.Id="sales-by-vendor"; g.FootNote= "Target by vendor : {0}".Fmt(targetByVendor.Format()); g.AddGridColum( c=> { c.HeaderText="Vendor"; c.CellRenderFunc=(row,index,dt)=> row.Vendor; c.FooterRenderFunc= ()=>"Total Sales ===>"; }); g.AddGridColum( c=> { c.HeaderText="Total"; c.CellRenderFunc=(row,index,dt)=> row.Total.Format(); c.CellStyle.TextAlign="right"; c.FooterRenderFunc=()=> sbv.Sum(f=>f.Total).Format(); c.FooterCellStyle.TextAlign="right"; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=>{ Cayita.HtmlWidgets.Core.TagBase r ; if(mailTarget.IsNullOrEmpty()) { r= new HtmlIcon(){Class="icon-circle"}; } else{ r= new HtmlParagragh(){Text= row.Total>=targetByVendor?"+":"x" }; } r.Style.Color= row.Total>targetByVendor?"green":"red"; return r; }; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=>{ HtmlLink link = new HtmlLink(); link.Url= "#"+row.Vendor.ReplaceAll(" ","-"); link.Text="see details"; return link.ToString(); }; }); return g; }
public void HtmlGrid_SetsViewContext() { htmlGrid.Html.ViewContext.Returns(new ViewContext()); htmlGrid.Html.ViewContext.HttpContext = new DefaultHttpContext(); Object actual = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).Grid.ViewContext; Object expected = htmlGrid.Html.ViewContext; Assert.Same(expected, actual); }
public HtmlGridTests() { html = Substitute.For<IHtmlHelper>(); html.ViewContext.Returns(new ViewContext()); html.ViewContext.HttpContext = new DefaultHttpContext(); grid = new Grid<GridModel>(new GridModel[8]); htmlGrid = new HtmlGrid<GridModel>(html, grid); grid.Columns.Add(model => model.Name); grid.Columns.Add(model => model.Sum); }
public void HtmlGrid_SetsGridQuery() { grid.Query = null; IReadableStringCollection expected = html.ViewContext.HttpContext.Request.Query; IReadableStringCollection actual = new HtmlGrid<GridModel>(html, grid).Grid.Query; foreach (String key in expected.Keys) Assert.Equal(expected[key], actual[key]); Assert.Equal(expected.Keys, actual.Keys); }
public void HtmlGrid_SetsGridQuery() { grid.Query = null; NameValueCollection expected = htmlHelper.ViewContext.HttpContext.Request.QueryString; NameValueCollection actual = new HtmlGrid<GridModel>(htmlHelper, grid).Grid.Query; foreach (String key in expected) Assert.Equal(expected[key], actual[key]); Assert.Equal(expected.AllKeys, actual.AllKeys); Assert.NotSame(expected, actual); }
public void HtmlGrid_SetsGrid() { IGrid<GridModel> actual = new HtmlGrid<GridModel>(null, grid).Grid; IGrid<GridModel> expected = grid; Assert.Same(expected, actual); }
public void HtmlGrid_SetsHtml() { IHtmlHelper actual = new HtmlGrid<GridModel>(html, grid).Html; IHtmlHelper expected = html; Assert.Same(expected, actual); }
HtmlGrid<Sale> BuildDetails(string vendor, List<Sale> sales, string mailTarget=null){ HtmlGrid<Sale> g = new HtmlGrid<Sale>(); g.DataSource=sales; if(! mailTarget.IsNullOrEmpty()) g.GridStyle= new GreyGridStyle(); // css = Inline Style else g.Css = new CayitaGridGrey(); // css = Style Sheet g.Title= "Sales by: {0}".Fmt(vendor); g.Id = vendor.ReplaceAll(" ", "-"); g.AddGridColum( c=> { c.HeaderText="Customer"; c.CellRenderFunc=(row,index,dt)=> row.Customer; c.FooterRenderFunc= ()=>"Total Sales ===>"; c.FooterCellColumnSpan=1; }); g.AddGridColum( c=> { c.HeaderText="Product"; c.CellRenderFunc=(row,index,dt)=> row.Product; }); g.AddGridColum( c=> { c.HeaderText="Date"; c.CellRenderFunc=(row,index,dt)=> row.Date.Format("MM/dd/yyyy"); }); g.AddGridColum( c=> { c.HeaderText="Price"; c.CellRenderFunc=(row,index,dt)=> row.Price.Format(); c.CellStyle.TextAlign="right"; c.FooterRenderFunc= ()=> sales.Sum(f=>f.Price).Format(); c.FooterCellStyle.TextAlign="right"; }); return g; }
HtmlGrid<Sale> BuildSalesGrid (List<Sale> sales) { HtmlGrid<Sale> g = new HtmlGrid<Sale>(); g.Css = new CayitaGridGrey(); // css = Style Sheet g.Title= "All Sales"; g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Customer; c.HeaderText="Vendor"; c.FooterRenderFunc= ()=>"Total Sales ===>"; c.FooterCellColumnSpan=3; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Customer; c.HeaderText="Customer"; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Product; c.HeaderText="Product"; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Date.Format("MM/dd/yyyy"); c.HeaderText="Date"; }); g.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Price; c.HeaderText="Price"; c.FooterRenderFunc= ()=> sales.Sum(f=>f.Price).Format(); }); return g; }
HtmlGrid<Author> BuildAuthorGrid (List<Author> users){ var grid = new HtmlGrid<Author>(){Name="Author"}; grid.DataSource= users; grid.Css = new Bootstrap(); grid.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Id; c.HeaderText="Id"; c.Hidden=true; }); grid.AddGridColum( c=> { c.CellRenderFunc= (row,index,dt)=> row.Name; c.HeaderText="Name"; }); grid.AddGridColum( c=> { c.HeaderText="City"; c.CellRenderFunc=(row,index,dt)=> row.City; }); grid.AddGridColum( c=> { c.CellRenderFunc= (row,index,dt)=> row.Comments; c.HeaderText="Comments"; }); grid.AddGridColum( c=> { c.HeaderText="Active?"; c.CellRenderFunc=(row,index,dt)=> { dt.Parent.Style.Color=row.Active?"black":"grey"; var itag = new HtmlIcon(){ Class= row.Active? "icon-ok-circle":"icon-ban-circle", }; return itag; }; c.CellStyle.TextAlign="center"; }); grid.AddGridColum( c=> { c.HeaderText=""; c.CellStyle.Width=new WidthProperty(){Unit="%",Value=10}; c.CellRenderFunc=(row,index,dt)=>{ var idiv = new HtmlDiv(); var itag = new HtmlIcon(){ Name="Author", Class="button-edit icon-edit", Url= "api/Author/read/{0}".Fmt( row.Id) }; itag.Style.Margin.Left=5; idiv.AddHtmlTag(itag); itag = new HtmlIcon(){ Class="button-delete icon-remove", Url= "api/Author/destroy/{0}".Fmt( row.Id) }; itag.Style.Margin.Left=5; itag.Style.Color="red"; idiv.AddHtmlTag(itag); return idiv; }; }); return grid; }
HtmlGrid<User> BuildUserGrid (List<User> users){ var grid = new HtmlGrid<User>(){Name="User"}; grid.DataSource= users; grid.Css = new Bootstrap(); grid.AddGridColum( c=> { c.CellRenderFunc=(row,index,dt)=> row.Id; c.HeaderText="Id"; c.Hidden=true; }); grid.AddGridColum( c=> { c.CellRenderFunc= (row,index,dt)=> row.Name; c.HeaderText="Name"; }); grid.AddGridColum( c=> { c.HeaderText="City"; c.CellRenderFunc=(row,index,dt)=> row.City; }); grid.AddGridColum( c=> { c.CellRenderFunc= (row,index,dt)=> row.Address; c.HeaderText="Address"; }); grid.AddGridColum( c=> { c.HeaderText="Birthday"; c.CellRenderFunc=(row,index,dt)=> row.DoB.Format("MM/dd/yyy"); c.CellStyle.TextAlign="center"; }); grid.AddGridColum( c=> { c.HeaderText="E-Mail"; c.CellRenderFunc=(row,index,dt)=> row.Email; }); grid.AddGridColum( c=> { c.HeaderText="Rating"; c.CellRenderFunc=(row,index,dt)=>{ dt.Parent.AddCssClass(row.Rating==10?"success":row.Rating<6?"warning":"" ); return row.Rating; }; c.CellStyle.TextAlign="center"; }); grid.AddGridColum( c=> { c.HeaderText="Level"; c.CellRenderFunc=(row,index,dt)=> { c.CellStyle.Color= row.Level=="A"?"green": row.Level=="B"?"orange":"red"; return row.Level; }; c.CellStyle.TextAlign="center"; }); grid.AddGridColum( c=> { c.HeaderText="Active?"; c.CellRenderFunc=(row,index,dt)=> { dt.Parent.Style.Color=row.IsActive?"black":"grey"; //return row.IsActive.Format(); var itag = new HtmlIcon(){ Class= row.IsActive? "icon-ok-circle":"icon-ban-circle", }; return itag; }; c.CellStyle.TextAlign="center"; }); grid.AddGridColum( c=> { c.HeaderText=""; c.CellStyle.Width=new WidthProperty(){Unit="%",Value=10}; c.CellRenderFunc=(row,index,dt)=>{ var idiv = new HtmlDiv(); var itag = new HtmlIcon(){ Name="User", Class="button-edit icon-edit", Url= "api/User/read/{0}".Fmt( row.Id) }; itag.Style.Margin.Left= 5; idiv.AddHtmlTag(itag); itag = new HtmlIcon(){ Class="button-delete icon-remove", Url= "api/User/destroy/{0}".Fmt( row.Id) }; itag.Style.Margin.Left= 5; itag.Style.Color="red"; idiv.AddHtmlTag(itag); return idiv; }; }); return grid; }
public void HtmlGrid_SetsHtml() { IHtmlHelper expected = Substitute.For<IHtmlHelper>(); IHtmlHelper actual = new HtmlGrid<GridModel>(expected, grid).Html; Assert.Same(expected, actual); }
public void HtmlGrid_SetsHtml() { HtmlHelper expected = HtmlHelperFactory.CreateHtmlHelper(); HtmlHelper actual = new HtmlGrid<GridModel>(expected, grid).Html; Assert.Same(expected, actual); }