gpt4 book ai didi

javascript - 将复选框列添加到剑道网格

转载 作者:行者123 更新时间:2023-12-01 01:27:26 26 4
gpt4 key购买 nike

我有一个剑道网格,最初有一组列,我试图向其中添加两个复选框列。

<script id="sectionPage" type="text/kendo-tmpl">
@(Html.Kendo().Grid<SectionPageModel>()
.Name("grid_#=SectionID#")
.HtmlAttributes(new { @class = "detail-grid" })
.Columns(columns =>
{
columns.Select().Width(60);
columns.Bound(o => o.SectionPageID).Hidden(true);
columns.Bound(o => o.SectionID).Hidden(true);
columns.Bound(o => o.PageID).Hidden(true);
columns.Bound(o => o.PageCD).EditorTemplateName("PageCDDropDown").Title("Page").Width(225);
columns.Bound(o => o.PageTitle).Hidden(true);
columns.Bound(o => o.PageTitleOverride).Width(300);
columns.Bound(o => o.AccountID).Hidden(true);
columns.Bound(o => o.AccountCD).EditorTemplateName("AccountCDAutoComplete").Width(120).Title("Account");
columns.Bound(o => o.EffectiveDate).Format("{0:MM/dd/yyyy}").Width(60).Hidden(true);
columns.Bound(o => o.EndDate).Format("{0:MM/dd/yyyy}").Width(60).Hidden(true);
columns.Bound(o => o.SPSortOrder).ClientTemplate("<span class='spSortSpan'>\\#if(SPSortOrder != null) {\\# \\#=SPSortOrder\\# \\#} else {\\# \\#=0\\# \\#}\\#</span>").Title("Sort Order");
columns.Bound(o => o.AddedBy);
columns.Bound(o => o.AddedOn).Format("{0:MM/dd/yyyy}");
columns.Bound(o => o.UpdatedBy);
columns.Bound(o => o.UpdatedOn).Format("{0:MM/dd/yyyy}");
columns.Bound(o => o.FirstRun).ClientTemplate("<input id='FirstRun' name='FirstRun' class='chkbx' type='checkbox' #= FirstRun ? checked='checked' : '' #/>").Title("First Run").Width(110);
columns.Bound(o => o.SecondRun).ClientTemplate("<input id='SecondRun' name='SecondRun' type='checkbox' #= SecondRun ? checked='checked' : '' # class='chkbx'/>").Title("Second Run").Width(110);
})
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add Page");
toolbar.Save().SaveText("Save Pages");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(e => e.DataBound("detailGrid_onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(f => f.SectionPageID);
model.Field(f => f.PageTitle).Editable(false);
model.Field(f => f.AddedOn).Editable(false);
model.Field(f => f.AddedBy).Editable(false);
model.Field(f => f.UpdatedOn).Editable(false);
model.Field(f => f.UpdatedBy).Editable(false);
}
)
.ServerOperation(false)
.Read(read => read.Action("SectionPage", "Document", new { sectionID = "#=SectionID#" }))
.Create(create => create.Action("SectionPage_Create", "Document").Data("detailGrid_onAdditionalData"))
.Update(update => update.Action("SectionPage_Create", "Document"))
.Destroy(delete => delete.Action("SectionPage_Delete", "Document"))

)
.Scrollable()
.Sortable()
.Events(e => e.SaveChanges("detailGrid_onSaveChanges"))
.ToClientTemplate()

)
</script>

这两个复选框被添加到以下两行中:

 columns.Bound(o => o.FirstRun).ClientTemplate("<input id='FirstRun' name='FirstRun' class='chkbx'  type='checkbox'  #= FirstRun ? checked='checked' : '' #/>").Title("First Run").Width(110);
columns.Bound(o => o.SecondRun).ClientTemplate("<input id='SecondRun' name='SecondRun' type='checkbox' #= SecondRun ? checked='checked' : '' # class='chkbx'/>").Title("Second Run").Width(110);

没有这两行,网格会正常渲染,但是添加这两行会导致以下错误:

Invalid template:'    <div class="k-widget k-grid detail-grid" id="grid_#=SectionID#"><div class="k-header k-grid-toolbar k-grid-top"><a class="k-button k-button-icontext k-grid-add" href="/Document/SectionPage?sectionID=%23%3DSectionID%23&grid_%23%3DSectionID%23-mode=insert"><span class="k-icon k-i-add">....

当我从两个标签中删除三元运算符时(#= FirstRun ?checked='checked' : '' ##= SecondRun ?checked='checked' : '' # ),不会引发错误。

将两个复选框列添加到此网格的正确方法是什么?

最佳答案

尝试在 \\ 中添加三元运算,

columns.Bound(o => o.FirstRun)
.ClientTemplate("<input id='FirstRun' name='FirstRun' class='chkbx' type='checkbox' \\#= FirstRun ? checked='checked' :'' \\# />")
.Title("First Run").Width(110);

columns.Bound(o => o.SecondRun)
.ClientTemplate("<input id='SecondRun' name='SecondRun' type='checkbox' \\#= SecondRun ? checked='checked' :'' \\# class='chkbx'/>")
.Title("Second Run").Width(110);

关于javascript - 将复选框列添加到剑道网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53641693/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com