I have a grid that I toggle the visibility of certain columns on and off in certain user situations.
Hiding the columns works fine, but when I add a row to the grid, the columns I hid become visible again as soon as I click the grid's "Add" button.
I'm not sure if this is desired or not, but I'd appreciate a workaround if it's not considered a bug. Thanks!
Script that hides the columns:
Grid Databound function that calls SetItemGridView:
Grid code (simplified for brevity):
Hiding the columns works fine, but when I add a row to the grid, the columns I hid become visible again as soon as I click the grid's "Add" button.
I'm not sure if this is desired or not, but I'd appreciate a workaround if it's not considered a bug. Thanks!
Script that hides the columns:
function SetItemGridView(isManual) {
var itemGrid = $("#ItemGrid").data("kendoGrid");
if (isManual) {
itemGrid.showColumn("MyTestCol");
} else {
itemGrid.hideColumn("MyTestCol");
}
}
function ConfigureItemGrid(e) {
SetItemGridView($("#IsManual").length > 0 ? $("#IsManual").is(":checked") : true);
}
Grid code (simplified for brevity):
@(Html.Kendo().Grid(Model)
.Name("ItemGrid")
.Columns(columns =>
{
columns.Bound(i => i.MyTestCol).Width(100);
columns.Command(command =>
{
command.Destroy();
}).Width(60);
})
.Events(e =>
{
e.DataBound("ConfigureItemGrid");
e.Edit("onItemGridEdit");
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable =>
{
editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom);
})
.Navigatable(navigatable => navigatable.Enabled(true))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(i => i.ItemModelID);
})
.Create(create => create.Action("CreateProducts", "ItemGrid"))
.Read(read => read.Action("GetProducts", "ItemGrid"))
.Update(update => update.Action("UpdateProducts", "ItemGrid"))
.Destroy(destroy => destroy.Action("DeleteProducts", "ItemGrid"))
)
)