dobtco / jquery-resizable-columns

Resizable table columns for jQuery.
http://dobtco.github.io/jquery-resizable-columns
535 stars 170 forks source link

Need ability to skip sizing of some columns (Checkbox row) #69

Open millebi opened 7 years ago

millebi commented 7 years ago

If a table has a column that contains just a checkbox (for selection of multiple of rows) or action icons these columns can be resized to strange results (user can make it huge or tiny, automatic sizing can cut off the checkbox, etc...). I've done a rudimentary change in an older version that probably can be done better. Here's what I have:

Call to setup (don't resize column 0, or 6): this.$el.find("table").resizableColumns({fixed:[0,6]});

Functionality change: ResizableColumns.prototype.assignPercentageWidths = function() { return this.$tableHeaders.each((function(_this) { var ccnt = 0; return function(_, el) { var $el, l = _this.options.fixed; $el = $(el); if(l) { for(var i=0; i < l.length; i++) { if(ccnt == l[i]) return } } return setWidth($el[0], $el.outerWidth() / _this.$table.width() * 100, ccnt++); }; })(this)); };

If there was a method to disallow automatically resizing some columns or disabling resizing of some columns, I couldn't find it and maybe someone else can make this even better.