Minimum Width for Grid Columns

4 posts, 0 answers
  1. Bjorn
    Bjorn avatar
    4 posts
    Member since:
    May 2016

    Posted 14 Sep Link to this post

    This seems to be a pretty good example, but unfortunately it doesn't work:

    http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Layout/apply-minimum-width-during-column-resize

    Is this deprecated? The binding to the resizable-events doesn't seem to work.

     

  2. Bjorn
    Bjorn avatar
    4 posts
    Member since:
    May 2016

    Posted 14 Sep in reply to Bjorn Link to this post

    OK nevermind, it works!
  3. Kendo UI is VS 2017 Ready
  4. Patrick
    Admin
    Patrick avatar
    172 posts

    Posted 14 Sep Link to this post

    Hello Bjorn,

    Glad the example is working for you!  

    Regards,
    Patrick
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  5. Bjorn
    Bjorn avatar
    4 posts
    Member since:
    May 2016

    Posted 14 Sep Link to this post

    var minColumnWidth,
                th,
                field,
                column,
                idx,
                grid = $('#grid').data('kendoGrid');
     
            grid.resizable.bind("start", function(e) {
                th = $(e.currentTarget).data("th");
                field = th.data("field");
                idx = th.index();
     
                var column = $.grep(grid.columns, function (item) {
                    return item.field === field;
                })[0];
     
                minColumnWidth = parseInt(column.minwidth,10);
            });
     
            me.kendoGridObject.resizable.bind("resize", function(e) {
                if (th.width() < minColumnWidth) {
                    // the next line is ONLY needed if Grid scrolling is enabled
                    grid.thead.closest("table").children("colgroup").find("col").eq(idx).width(minColumnWidth);
                    grid.tbody.closest("table").children("colgroup").find("col").eq(idx).width(minColumnWidth);
                }
            });

     

    This is our solution, maybe this helps somebody. We're now able to configure the minimum column width through

    columns: {
        {
            minwidth:"200px"
        }
    }

Back to Top
Kendo UI is VS 2017 Ready