public void CanAddColumnFromList() { var grid = new Grid("testGrid"); IList<Column> column = new List<Column> { new Column("testColumn1") }; grid.AddColumns(column); StringAssert.Contains("name:'testColumn1',", grid.ToString()); StringAssert.Contains("index:'testColumn1'", grid.ToString()); JavascriptAssert.IsValid(grid.RenderJavascript()); }
public void CanAddColumnFromList() { var grid = new Grid("testGrid"); IList <Column> column = new List <Column> { new Column("testColumn1") }; grid.AddColumns(column); StringAssert.Contains("name:'testColumn1',", grid.ToString()); StringAssert.Contains("index:'testColumn1'", grid.ToString()); JavascriptAssert.IsValid(grid.RenderJavascript()); }
public Task Should_Add_Empty_Row() { // Given var console = new PlainConsole(width: 80); var grid = new Grid(); grid.AddColumns(2); grid.AddRow("Foo", "Bar"); grid.AddEmptyRow(); grid.AddRow("Qux", "Corgi"); // When console.Render(grid); // Then return(Verifier.Verify(console.Output)); }
public Task Should_Use_Default_Padding() { // Given var console = new PlainConsole(width: 80); var grid = new Grid(); grid.AddColumns(3); grid.AddRow("Foo", "Bar", "Baz"); grid.AddRow("Qux", "Corgi", "Waldo"); grid.AddRow("Grault", "Garply", "Fred"); // When console.Render(grid); // Then return(Verifier.Verify(console.Output)); }
public void Should_Add_Empty_Row() { // Given var console = new PlainConsole(width: 80); var grid = new Grid(); grid.AddColumns(2); grid.AddRow("Foo", "Bar"); grid.AddEmptyRow(); grid.AddRow("Qux", "Corgi"); // When console.Render(grid); // Then console.Lines.Count.ShouldBe(3); console.Lines[0].ShouldBe("Foo Bar "); console.Lines[1].ShouldBe(" "); console.Lines[2].ShouldBe("Qux Corgi"); }
public void Should_Use_Default_Padding() { // Given var console = new PlainConsole(width: 80); var grid = new Grid(); grid.AddColumns(3); grid.AddRow("Foo", "Bar", "Baz"); grid.AddRow("Qux", "Corgi", "Waldo"); grid.AddRow("Grault", "Garply", "Fred"); // When console.Render(grid); // Then console.Lines.Count.ShouldBe(3); console.Lines[0].ShouldBe("Foo Bar Baz "); console.Lines[1].ShouldBe("Qux Corgi Waldo"); console.Lines[2].ShouldBe("Grault Garply Fred "); }
public override void Process(TagHelperContext context, TagHelperOutput output) { QuerySet querySet = GridModel.QuerySet; output.TagName = "div"; output.Content.Clear(); string id = GridModel.JqgridId; if (Id.IsPresent()) { id = Id; } this.Id = $"grid-{id}"; string pager = $"pager-{id}"; Grid grid = new Grid(_dbContext, _rbacService, _applicationContext, _multiLang, _env, this.Id); if (Url.IsPresent()) { grid.SetUrl(Url); } else { if (IsTreeGrid) { grid.SetUrl($"{ _applicationContext.BaseUrl }/Core/Api/TreeDataList"); } else { grid.SetUrl($"{ _applicationContext.BaseUrl }/Core/Api/DataList"); } } if (EditUrl.IsPresent()) { grid.SetEditUrl(EditUrl); } else { if (InlineFormEnabled) { grid.SetEditUrl("clientArray"); } else { grid.SetEditUrl($"{_applicationContext.BaseUrl}/Core/Api/Inline/Persistence?from=grid"); } } if (Caption.IsPresent()) { grid.SetCaption(Caption); } if (AttachColumn != null) { grid.AddColumn(AttachColumn); } if (ExtraData != null) { grid.SetExtraData(ExtraData); } if (AttachColumns != null && AttachColumns.Any()) { grid.AddColumns(AttachColumns); } grid.SetLogicDelete(LogicDelete); //鉴权列 if (RegisterAuthority) { string cols = GetColumnPermission(querySet); if (cols.IsPresent()) { querySet.QueryCols = cols; } } grid.SetQueryOption(querySet); //获取数据时ajax post数据 grid.SetPostData(new { QuerySet = querySet }); //鉴权操作 if (RegisterAuthority) { string authorize = AuthenticationButton(querySet); //设置操作 SetGirdOper(grid, authorize); } else { SetGridDefaultOper(grid); } grid.SetAutoWidth(AutoWidth); grid.SetDataType(SourceType); grid.SetViewRecords(ViewRecords); grid.SetShrinkToFit(ShrinkFit); grid.SetColMenu(ColMenu); if (Height > 0) { grid.SetHeight(Height); } if (Wrapper.IsPresent()) { string[] wrapper = Wrapper.Split(','); if (wrapper.Length > 1) { grid.SetInsideTabControl($"{wrapper[0]}", $"{wrapper[1]}"); } else { grid.SetInsideElement(Wrapper); } } else { grid.SetInsideWidget(); } if (GridModel.IsMulti) { grid.SetMultiSelect(true); //grid.SetMultiBoxOnly(true); } else { if (MultiSelect) { grid.SetMultiSelect(MultiSelect); } if (MultiBoxOnly) { grid.SetMultiBoxOnly(MultiBoxOnly); } } if (RowNum != 10) { grid.SetRowNum(RowNum); } grid.SetRowNumbers(RowNumbers); if (InlineFormEnabled || InlineGridEnabled) { grid.SetEditRowModel(EditRowModel.Inline); } grid.SetFooterRow(FooterRow); grid.SetUserDataOnFooter(UserdataFooter); if (IsTreeGrid) { if (ExpandColumn.IsPresent()) { grid.SetExpandColumn(ExpandColumn); } grid.EnableTreeGrid(); } if (OnGridComplete.IsPresent()) { if (OnGridComplete.Contains("(")) { grid.OnGridComplete($"{OnGridComplete};"); } else { grid.OnGridComplete($"{OnGridComplete}();"); } } if (OnDblclickRow.IsPresent()) { grid.OnDblClickRow(OnDblclickRow); } if (OnFormInitAdd.IsPresent()) { if (OnFormInitAdd.Contains("(")) { grid.OnAddAfterInitDataForm($"{OnFormInitAdd};"); } else { grid.OnAddAfterInitDataForm($"{OnFormInitAdd}();"); } } if (OnFormInitEdit.IsPresent()) { if (OnFormInitEdit.Contains("(")) { grid.OnEditAfterInitDataForm($"{OnFormInitEdit};"); } else { grid.OnEditAfterInitDataForm($"{OnFormInitEdit}();"); } } if (OnSelectRow.IsPresent()) { if (OnSelectRow.Contains("(")) { grid.OnSelectRow($"{OnSelectRow};"); } else { grid.OnSelectRow($"{OnSelectRow}(rowid, status);"); } } if (SearchToolbar) { grid.SetSearchToolbar(SearchToolbar); } if (SubgridRowexpanded.IsPresent()) { grid.SetSubGridRowExpanded(SubgridRowexpanded); } if (GroupHeaders != null && GroupHeaders.Any()) { grid.SetGroupHeaders(GroupHeaders); } grid.SetPager(pager); output.Content.AppendHtml(grid.ToString()); }