This is a migrated thread and some comments may be shown as answers.

Hidden columns become visible after adding a row to the grid

2 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jark Monster
Top achievements
Rank 1
Jark Monster asked on 27 Jun 2013, 12:58 PM
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:
function SetItemGridView(isManual) {
    var itemGrid = $("#ItemGrid").data("kendoGrid");
 
    if (isManual) {
        itemGrid.showColumn("MyTestCol");
    } else {
        itemGrid.hideColumn("MyTestCol");
    }
}
Grid Databound function that calls SetItemGridView:
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"))
    )
)

2 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 01 Jul 2013, 07:40 AM
Hi Mark,


I tried to reproduce the issue with version 2013.1.514 but to no avail. To demonstrate this, I prepared the following JS Bin example. Please click on the "Hide column" button and then add a new row.

If the problem is still persisting, could you please isolate the issue in a small runnable project, so I could inspect it locally and assist you further? I am looking forward to hearing from you.

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jark Monster
Top achievements
Rank 1
answered on 01 Jul 2013, 12:56 PM
Dimiter,

I found the issue.  The checkbox that I reference in the databound function was losing it's checked status for some reason.  I'm not sure why it is doing this, but I can verify that it is definitely not an issue with Kendo.

Thanks for the JSBin.  It definitely helped me zero in on this!

Best,
-mark
Tags
Grid
Asked by
Jark Monster
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Jark Monster
Top achievements
Rank 1
Share this question
or