Hidden columns become visible after adding a row to the grid

3 posts, 0 answers
  1. Jark Monster
    Jark Monster avatar
    46 posts
    Member since:
    Jan 2012

    Posted 27 Jun 2013 Link to this post

    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. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2277 posts

    Posted 01 Jul 2013 Link to this post

    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!
  3. Jark Monster
    Jark Monster avatar
    46 posts
    Member since:
    Jan 2012

    Posted 01 Jul 2013 Link to this post

    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
Back to Top