Skip to content

Commit

Permalink
fixed bug around new row with zero records in child grid, fixed name …
Browse files Browse the repository at this point in the history
…getter
  • Loading branch information
Tony Germaneri committed Dec 16, 2016
1 parent 0cd324b commit 3150608
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-datagrid",
"main": "lib/main.js",
"version": "0.9.20",
"version": "0.9.21",
"ignore": [
"**/.*",
"node_modules",
Expand Down
17 changes: 10 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
function grid(args) {
args = args || {};
var defaultAttributes = [
['name', ''],
['tree', false],
['showNewRow', false],
['treeHorizontalScroll', false],
Expand Down Expand Up @@ -236,7 +237,7 @@
function stopPropagation(e) { e.stopPropagation(); }
function setStorageData() {
if (!attributes.saveAppearance) { return; }
localStorage.setItem(storageName + '-' + args.name, JSON.stringify({
localStorage.setItem(storageName + '-' + attributes.name, JSON.stringify({
sizes: sizes
}));
}
Expand Down Expand Up @@ -545,7 +546,7 @@
rowIndex: rowIndex,
container: container,
isGrid: isGrid,
gridId: (args.name || '') + d[uniqueId] + ':' + header[uniqueId],
gridId: (attributes.name || '') + d[uniqueId] + ':' + header[uniqueId],
parentGrid: intf,
value: cellStyle === 'headerCell'
? (header.title || header.name) : d[header.name]
Expand Down Expand Up @@ -685,7 +686,7 @@
cellHeight = rowHeight || (rowOpen ? style.treeGridHeight : style.cellHeight);
x = 0;
// don't draw a tree for the new row
if (r !== data.length - 1 && rowOpen) {
if (r !== data.length && rowOpen) {
treeGrid = childGrids[rd[uniqueId]];
treeGrid.visible = true;
treeGrid.childGridContainer.style.top =
Expand Down Expand Up @@ -714,6 +715,8 @@
if (attributes.showRowHeaders) {
x = headerCellWidth;
}
rowHeight = cellHeight = style.cellHeight;
rowOpen = false;
s.forEach(function forEachHeader(header, index) {
drawCell(newRow, data.length)(header, index);
});
Expand Down Expand Up @@ -879,7 +882,7 @@
if (!childGrids[rowId]) {
childGrids[rowId] = grid({
name: attributes.saveAppearance
? args.name + 'tree' + rowId : undefined,
? attributes.name + 'tree' + rowId : undefined,
height: h,
width: canvas.offsetWidth - headerCellWidth,
parentNode: {
Expand Down Expand Up @@ -2273,7 +2276,7 @@
if (!schema && data.length > 0) {
tempSchema = getSchemaFromData();
}
if (data.length === 0) {
if (!schema && data.length === 0) {
tempSchema = [{name: ''}];
}
createNewRowData();
Expand All @@ -2289,8 +2292,8 @@
if (!resize()) { draw(); }
}
});
if (args.name && attributes.saveAppearance) {
storedSettings = localStorage.getItem(storageName + '-' + args.name);
if (attributes.name && attributes.saveAppearance) {
storedSettings = localStorage.getItem(storageName + '-' + attributes.name);
if (storedSettings) {
try {
storedSettings = JSON.parse(storedSettings);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-datagrid",
"version": "0.9.20",
"version": "0.9.21",
"description": "Canvas based data grid",
"main": "./lib/main.js",
"scripts": {
Expand Down

0 comments on commit 3150608

Please sign in to comment.