Skip to content

Commit

Permalink
Merge branch 'side-by-side-patch-auto-width'
Browse files Browse the repository at this point in the history
  • Loading branch information
deitch committed Nov 18, 2015
2 parents 1b9943d + 93ff3b4 commit 9ec7211
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ Options

### The options are as follows:

* `width`: default width for a column for which no width is given. If no width is given, the default is 25px
* `width`: default width for a column for which no width is given. If no width is given, the default is `auto`.
* `columns`: an array of columns to create, on order. Each entry is an object with the following parameters:
* `tree`: boolean, whether the jstree should be placed in this column. Only the first `true` is accepted. If no column is set to `tree:true`, then the first column is used.
* `width`: width of the column in pixels. If no width is given, the default is 25 px **except for the last column**. In the last column, if not width is given, it is treated as 'auto' and fills the entire rest of the grid to the right.
* `width`: width of the column in pixels. If no width is given, the default is `auto` **except for the last column**. In the last column, if not width is given, it is treated as 'auto' and fills the entire rest of the grid to the right.
* `header`: string to use as a header for the column.
* `headerClass`: a CSS class to add to the header cell in this column
* `columnClass`: a CSS class to add to the header cell and the column cell
Expand Down
14 changes: 9 additions & 5 deletions jstreegrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
};

$.jstree.defaults.grid = {
width: 25
width: 'auto'
};

$.jstree.plugins.grid = function(options,parent) {
Expand Down Expand Up @@ -356,7 +356,9 @@
if (val) {hasHeaders = true;}
width = cols[i].width || defaultWidth;
borPadWidth = tr ? 1+6 : 2+8; // account for the borders and padding
width -= borPadWidth;
if (width !== 'auto') {
width -= borPadWidth;
}
margin = i === 0 ? 3 : 0;
col.css({width:width});
last = $("<th></th>").css(conf).css({"margin-left": margin}).addClass((tr?"ui-widget-header ":"")+"jstree-grid-header jstree-grid-header-cell jstree-grid-header-"+classAdd+" "+cl+" "+ccl).html(val).appendTo(header);
Expand Down Expand Up @@ -595,10 +597,10 @@
};
},
hoverInHandler = function (node, jsTreeInstance) {
return function() { jsTreeInstance.hover_node(node); }
return function() { jsTreeInstance.hover_node(node); };
},
hoverOutHandler = function (node, jsTreeInstance) {
return function() { jsTreeInstance.dehover_node(node); }
return function() { jsTreeInstance.dehover_node(node); };
},
i, val, cl, wcl, ccl, a, last, valClass, wideValClass, span, paddingleft, title, gridCellName, gridCellParentId, gridCellParent,
gridCellPrev, gridCellPrevId, gridCellNext, gridCellNextId, gridCellChild, gridCellChildId,
Expand Down Expand Up @@ -683,7 +685,9 @@
// get the width
paddingleft = 7;
width = col.width || defaultWidth;
width = tmpWidth || (width - paddingleft);
if (width !== 'auto') {
width = tmpWidth || (width - paddingleft);
}

last = dataCell.children("div#"+gridCellName+i);
if (!last || last.length < 1) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jstreegrid",
"description": "grid plugin for jstree",
"version": "3.2.9",
"version": "3.3.0",
"url": "https://github.com/deitch/jstree-grid",
"author": {"name":"Avi Deitcher","url":"https://github.com/deitch"},
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion treegrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
grid: {
columns: [
{width: 110, header: "Nodes",title:"_DATA_"},
{cellClass: "col1", value: "price", width: 60, header: "<i>Price</i>", title:"price", valueClass:"spanclass"},
{cellClass: "col1", value: "price", header: "<i>Price</i>", title:"price", valueClass:"spanclass"},
{cellClass: "col2", value: "size", header: "Qty", title:"size",valueClass:"spanclass"}
],
resizable:true,
Expand Down

0 comments on commit 9ec7211

Please sign in to comment.