Пример #1
0
        public void HtmlGrid_SetsPartialViewName()
        {
            String actual   = new HtmlGrid <GridModel>(htmlGrid.Html, htmlGrid.Grid).PartialViewName;
            String expected = "MvcGrid/_Grid";

            Assert.Equal(expected, actual);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        public void HtmlGrid_SetsGrid()
        {
            IGrid <GridModel> actual   = new HtmlGrid <GridModel>(null, grid).Grid;
            IGrid <GridModel> expected = grid;

            Assert.Same(expected, actual);
        }
Пример #5
0
        public void HtmlGrid_SetsDefaultPartialViewName()
        {
            String actual = new HtmlGrid<GridModel>(null, grid).PartialViewName;
            String expected = "MvcGrid/_Grid";

            Assert.Equal(expected, actual);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #9
0
        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);
        }
Пример #11
0
        public void HtmlGrid_SetsHtml()
        {
            IHtmlHelper actual   = new HtmlGrid <GridModel>(html, grid).Html;
            IHtmlHelper expected = html;

            Assert.Same(expected, actual);
        }
Пример #12
0
        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);
        }
Пример #13
0
        public void HtmlGrid_SetsHtml()
        {
            HtmlHelper expected = HtmlHelperFactory.CreateHtmlHelper();
            HtmlHelper actual   = new HtmlGrid <GridModel>(expected, grid).Html;

            Assert.Same(expected, actual);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #17
0
        public void HtmlGrid_SetsHtml()
        {
            IHtmlHelper expected = Substitute.For <IHtmlHelper>();
            IHtmlHelper actual   = new HtmlGrid <GridModel>(expected, grid).Html;

            Assert.Same(expected, actual);
        }
Пример #18
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        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);
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        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);
        }
Пример #25
0
        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);
        }
Пример #26
0
        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);
        }
Пример #27
0
        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);
        }
Пример #29
0
        public void HtmlGrid_SetsHttpContext()
        {
            grid.ViewContext = null;

            ViewContext actual = new HtmlGrid<GridModel>(html, grid).Grid.ViewContext;
            ViewContext expected = html.ViewContext;

            Assert.Same(expected, actual);
        }
Пример #30
0
        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);
        }
Пример #31
0
        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);
        }
Пример #32
0
        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);
        }
Пример #33
0
        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);
        }
Пример #34
0
        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);
        }
Пример #35
0
        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);
        }
Пример #36
0
        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);
        }
Пример #37
0
        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);
        }
Пример #38
0
        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);
        }
Пример #39
0
        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;
		}
Пример #41
0
        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);
        }
Пример #42
0
        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);
        }
Пример #43
0
        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);
        }
Пример #44
0
        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);
        }
Пример #45
0
        public void HtmlGrid_SetsGrid()
        {
            IGrid<GridModel> actual = new HtmlGrid<GridModel>(null, grid).Grid;
            IGrid<GridModel> expected = grid;

            Assert.Same(expected, actual);
        }
Пример #46
0
        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;
		}
Пример #51
0
        public void HtmlGrid_SetsHtml()
        {
            IHtmlHelper expected = Substitute.For<IHtmlHelper>();
            IHtmlHelper actual = new HtmlGrid<GridModel>(expected, grid).Html;

            Assert.Same(expected, actual);
        }
Пример #52
0
        public void HtmlGrid_SetsHtml()
        {
            HtmlHelper expected = HtmlHelperFactory.CreateHtmlHelper();
            HtmlHelper actual = new HtmlGrid<GridModel>(expected, grid).Html;

            Assert.Same(expected, actual);
        }