New to Kendo UI for jQuery? Download free 30-day trial

Disable Resizing for Specific Columns in the Grid

Environment

Product Progress® Kendo UI® Grid for jQuery

Description

How can I disable column resizing for specific columns in the Kendo UI Grid for jQuery?

Solution

Column resizing is enabled or disabled for all Grid columns.

The following example demonstrates how to prevent resizing for the "bar" column.

    <p>The <strong>bar</strong> column cannot be resized:</p>
    <div id="grid"></div>
    <script>
        $(function(){
            $("#grid").kendoGrid({
               dataSource: {
                   data: [
                    {foo: "foo 1", bar: "bar 1", baz: "baz 1"},
                    {foo: "foo 2", bar: "bar 2", baz: "baz 2"}
                   ]
               },
               resizable: true,
               sortable: true
            });

            var grid = $("#grid").data("kendoGrid");

            grid.resizable.bind("start", function(e) {
                if ($(e.currentTarget).data("th").data("field") == "bar") {
                  e.preventDefault();
                  setTimeout(function(){
                    grid.wrapper.removeClass("k-grid-column-resizing");
                    $(document.body)
                      .add(".k-grid th")
                      .add(".k-grid th .k-link")
                      .css("cursor", "");
                  });
                }
            });
        });
    </script>

See Also

In this article