-2
我有一個kendo網格視圖,並且使用由錨標籤和標籤組成的客戶端模板。我需要做的是在網格視圖的onDatabound事件中隱藏錨標籤。Kendo UI Grid在dataBound上的客戶端模板中隱藏控件
這裏是電網
@(Html.Kendo().Grid(Model.GridView.DataSource)
.Name("grdRole")
.Columns(columns =>
{
columns.Command(command => command.Edit()).Width(110);
columns.Bound(p => p.Code);
columns.Bound(p => p.Name);
columns.Bound(p => p.Id).ClientTemplate("<a id='lnkDisplay' href='' onclick='return linkOnClick()'> Display Data</a> <label id='lblShow'> gfhfhf</label> ").Title("Data");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Events(x =>
{
x.Edit("onEdit");
x.Save("onSave");
x.DataBound("onDataBound");
})
.ToolBar(toolBar => toolBar.Create())
.Sortable(x => x.Enabled(false))
.Scrollable(x => x.Height("auto"))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
})
.Read(read => read.Action("OnGridRead", "Grid"))
.Create(create => create.Action("OnGridCreate", "Grid"))
.Update(update => update.Action("OnGridUpdate", "Grid"))
)
)
在這裏,我所試圖做的..
function onDataBound(e) {
var trs = this.wrapper.find('.k-grid-content tr');
trs.each(function() {
var id = this.childNodes[5].childNodes[0].hide();
});
});
它給了我下面的錯誤..
TypeError: this.childNodes[5].firstChild.hide is not a function
它因爲你在DOM元素上調用jquery方法,但它必須是jquery對象 –