From 34867b118e85f2343c6ed5aca8ac8da668a1bad2 Mon Sep 17 00:00:00 2001 From: Marin Procureur Date: Tue, 2 Feb 2016 17:30:46 +0100 Subject: [PATCH] First draft of a csv renderer #4 --- examples/simpleExample/simpleExample.js | 58 +- min/ij.min.js | 932 +++++++++++++++++++++++- src/js/ij.Core.js | 31 +- 3 files changed, 950 insertions(+), 71 deletions(-) diff --git a/examples/simpleExample/simpleExample.js b/examples/simpleExample/simpleExample.js index 07ad425..18d4489 100644 --- a/examples/simpleExample/simpleExample.js +++ b/examples/simpleExample/simpleExample.js @@ -77,11 +77,7 @@ var Renderer = { rowObject, rowObject, (order || 0), - this.renderer.addAttribute( - this.renderer.createElementWithText("th", rowObject), - "id", - this.template.getAttribute("rowHeader","idPrefix") + rowNumber - ), + rowObject, (open || true), (hidden || true) ) @@ -100,11 +96,7 @@ var Renderer = { columnObject, columnObject, (order || 0), - this.renderer.addAttribute( - this.renderer.createElementWithText("th", columnObject), - "id", - this.template.getAttribute("columnHeader","idPrefix") + columnNumber - ), + columnObject, (open || true), (hidden || true) ) @@ -113,59 +105,19 @@ var Renderer = { }, renderCell : function(rowsNumbers, columnsNumbers, cellData, eventsCallBacks){ - if (cellData && cellData.length > 0 && cellData[0]) { - var cell = this.renderer.createElementWithText("td", cellData[0]); - this.renderer.addAttribute(cell, "data-toggle", "popover"); - this.renderer.addAttribute(cell, "data-original-title", "Summary (first relation)"); - this.renderer.addAttribute(cell, "data-content", - this._getSummaryHoverCell(cellData) - ); - this.renderer.addAttribute(cell, "data-html", "true"); - this.renderer.addAttribute(cell, "data-container", "body"); - } - else { - var cell = this.renderer.createElement("td"); - } - cell = this.addEventsToRendering(cell, - eventsCallBacks); - for (var row in rowsNumbers){ - this.renderer.addClasses(cell, - [this.template.getAttribute("rowHeader", "classPrefix") + - rowsNumbers[row]]); - } - for (var column in columnsNumbers){ - return this.renderer.addClasses(cell, - [this.template.getAttribute("columnHeader", "classPrefix") + - columnsNumbers[column]]); - } + return cellData[0]; }, reRenderColumn : function(renderedColumn, events) { - if (!renderedColumn.children) { - var vtext = this.renderer.createElement("div", - ["vtext"]); - var vtextInner = this.renderer.createElementWithText("div", - renderedColumn.label, - ["vtext__inner"]); - renderedColumn.rendering.textContent = ""; - this.appendChild(vtext, - vtextInner); - this.appendChild(renderedColumn.rendering, - vtext); - } - renderedColumn.rendering = this.addEventsToRendering(renderedColumn.rendering, - events); return renderedColumn; }, reRenderRow : function(renderedRow, events) { - renderedRow.rendering = this.addEventsToRendering(renderedRow.rendering, - events); return renderedRow; } }; -Renderer = Class.extend(DefaultHTMLRenderer, Renderer); +Renderer = Class.extend(csvExportRenderer, Renderer); // @@ -289,7 +241,7 @@ component.renderer.template.addIdPrefix("columnHeader", component.renderer.template.addIdPrefix("rowHeader", "r"); -ij.setWorkspace(document.getElementById("matrix")); +ij.setWorkspace(""); var start = new Date(); ij.display(); console.log(new Date() - start); diff --git a/min/ij.min.js b/min/ij.min.js index 4f431a1..1628df9 100644 --- a/min/ij.min.js +++ b/min/ij.min.js @@ -1 +1,931 @@ -var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){},row:null,column:null,object:null,state:null,setState:function(e){this.state=e},getState:function(){return this.state}};r=Class.create(r);e.DataCell=r;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){},setState:function(e){this.state=e},getState:function(){return this.state}};r=Class.create(r);e.DataHeader=r;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){}};r=Class.create(r);e.State=r;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(e){if(!e){return}else{for(var r in e){this[r]=e[r]}}},params:{},dataprovider:null,controller:null,renderer:null,cache:null,workspace:null,cellsMap:[],init:function(e){for(var r in e){this.params[r]=e[r]}},setWorkspace:function(e){console.log(e);if(typeof e!=="undefined")this.workspace=e;else this.workspace=document.body;return this},getWorkspace:function(){return this.workspace},setDataProvider:function(r){if(typeof r!=="undefined")this.dataprovider=r;else this.dataprovider=new e.IIJDataProvider(this);return this.dataprovider},setController:function(r){if(r)this.controller=r;else this.controller=new e.IIJController(this);return this.controller},setRenderer:function(r){if(r)this.renderer=r;else this.renderer=new e.IIJRenderer(this);return this},_checkDependencies:function(){console.log("Something is missing : ");console.log("Checking DataProvider : ",this.dataProvider);console.log("Checking controller : ",this.controller);console.log("Checking DataProvider : ",this.renderer);console.log("Checking Workspace : ",this.workspace);console.log("Checking DataHandler : ",this.dataHandler);if(!this.renderer||!this.dataProvider||!this.dataHandler||!this.controller||!this.workspace){return false}else{return true}},getRenderedRows:function(e){var r=new Array;if(e)for(var n=0;nu){e[s][u].children=new Array;if(e[s][u].object){e[s][u].children.push(this._cloneHeader(e[s][u],r));delete e[s][u].object}if(e[s][u].hasSummary){var c=this.renderer.renderSummary(e[s][u],r);c.summary=true;e[s][u].children.push(c)}}i[d]=e[s][u]}else{if(u>0){var h=false;for(var f in l){if(l[f].id&&l[f].id==e[s][u].id){h=true;break}}if(h!=true){var p=e[s][u].id;var g=i[d];this._deleteNode(p,t.root);l.push(g);delete i[d];i[d]=g}}if(e[s].length-1>u){if(!i[d].children){i[d].children=new Array;if(i[d].object){i[d].children.push(this._cloneHeader(e[s][u],r));i[d].children[0].object=i[d].object;delete i[d].object}}}}l=i[d].children}}return t.root},_deleteNode:function(e,r){for(var n in r){if(r[n].id==e)delete r[n];else if(r[n].children)this._deleteNode(e,r[n].children)}},_cloneHeader:function(e,r){var n={};for(var t in e){if(t=="label")n[t]=e[t]+" [object]";else if(t=="children")continue;else if(t=="order")n[t]=-1;else if(t=="id"){n[t]=e[t]+"_child"}else if(t=="rendering"){n[t]=this.renderer.setId(e[t],this.renderer.getIdPrefix(r)+n.id)}else n[t]=e[t]}n.type=r;return n},orderRenderedTree:function(e){var r=new Date;var n=new Array,t=new Array;for(var i in e){if(!n[e[i].order])n[e[i].order]=new Array;n[e[i].order].push(e[i]);if(e[i].children)e[i].children=this.orderRenderedTree(e[i].children)}if(n["-1"])t=t.concat(this.alphabeticalSort(n["-1"]));for(var i in n){if(i!=-1)t=t.concat(this.alphabeticalSort(n[i]))}return t},alphabeticalSort:function(e){if(this.sort)return e.sort(function r(e,n){if(e.labeln.label)return 1;return 0});else return e},getTreeDepth:function(e){var r=0;for(var n in e){if(e[n].children){var t=this.getTreeDepth(e[n].children);e[n].group=true;if(t>r)r=t}}return r+1},applyTreeDepth:function(e,r){var n=new Date;for(var t in e){if(e[t].children&&e[t].open==true){e[t].depth=1;e[t].children=this.applyTreeDepth(e[t].children,r-1)}else{e[t].depth=r}}return e},populateSummaries:function(e){for(var r in e){if(e[r].hasSummary&&e[r].open==true){e[r].children[e[r].children.length-1].object=new Array;var n=this._getObjectsFromTree(e[r].children,false);e[r].children[e[r].children.length-1].object=n}if(e[r].children&&e[r].open==true)this.populateSummaries(e[r].children)}},_preRenderColumns:function(e,r){console.profile("_preRenderColumns");if(e){var n=this.getRenderedColumns(e);var n=this.buildRenderedTree(n,"columnHeader");n=this.orderRenderedTree(n)}else if(this.columns&&this.columns.rendering){var n=this.columns.rendering}else{return}for(var t in n){n[t]=this.getGroupSpan(n[t]).renderedTreeNode}if(!this.hideSummaries)this.populateSummaries(n);var i=this.getTreeDepth(n);this.applyTreeDepth(n,i);this.applyOnRenderedObjects(n,this.renderer.applyColSpan.bind(this.renderer),"span");this.applyOnRenderedObjects(n,this.renderer.applyRowSpan.bind(this.renderer),"depth");this.applyClasses(n,this.renderer.addClasses.bind(this.renderer),null,r);console.profileEnd();return{depth:i,rendering:n}},displayColumns:function(e,r){var n=this.renderer.renderColumnsContainer();var t=this.buildColumns(e.rendering);var i={rendering:this.renderer.renderLeftUpperCorner(),colspan:r||1,rowspan:e.depth||1};i.rendering=this.renderer.applyColSpan(i.rendering,i["colspan"]);i.rendering=this.renderer.applyRowSpan(i.rendering,i["rowspan"]);if(e.rendering.length>0)t[1].unshift(i.rendering);for(var o in t){var s=this.renderer.renderColumnsLevelContainer();for(var a in t[o]){this._appendChild(s,t[o][a])}this._appendChild(n,s)}this._appendChild(this.container,n)},buildColumns:function(e,r){r=typeof r!=="undefined"?r:1;var n=new Array;n[r]=new Array;for(var t in e){e[t]=this.renderer.reRenderColumn(e[t],this._getHeaderEventsCallbacks(e[t]));n[r].push(e[t].rendering);if(e[t].children&&(e[t].open!=false&&e[t].open!="false")){var i=this.buildColumns(e[t].children,r+1);for(var o in i){if(!n[o])n[o]=new Array;for(var s in i[o]){n[o].push(i[o][s])}}}}return n},_preRenderRows:function(e,r){console.profile("rows");if(e){var n=this.buildRenderedTree(this.getRenderedRows(e),"rowHeader");n=this.orderRenderedTree(n)}else if(this.rows&&this.rows.rendering){var n=this.rows.rendering}else{return}for(var t in n){n[t]=this.getGroupSpan(n[t],1).renderedTreeNode}if(!this.hideSummaries)this.populateSummaries(n);var i=this.getTreeDepth(n);this.applyTreeDepth(n,i);this.applyOnRenderedObjects(n,this.renderer.applyRowSpan.bind(this.renderer),"span");this.applyOnRenderedObjects(n,this.renderer.applyColSpan.bind(this.renderer),"depth");this.applyClasses(n,this.renderer.addClasses.bind(this.renderer),null,r);console.profileEnd();return{depth:i,rendering:n}},displayData:function(e,r){if(!this.container)this.container=this.renderer.renderContainer();var n=this.renderer.renderRowsContainer();if(e&&r)e=this.buildRows(e.rendering,r).rows;else if(e)e=this.buildRows(e.rendering,null).rows;else e=this.buildMatrix();for(var t in e){this._appendChild(n,e[t])}this._appendChild(this.container,n)},buildMatrix:function(){var e=this.dataprovider.getData(),r=new Array,n,t;console.log(e);for(var i=0;i0)for(var i in e){var o=this.renderer.renderRowContainer();if(e[i].children&&(e[i].open=="false"||e[i].open==false)){e[i].rendering=this.renderer.applyRowSpan(e[i].rendering,2)}e[i]=this.renderer.reRenderRow(e[i],this._getHeaderEventsCallbacks(e[i]));this._appendChild(o,e[i].rendering);if(e[i].summary){var s=this._renderRowSummary(r,n,e[i]);this._appendChildren(o,s);n++;t.push(o)}else if(e[i].object){var s=this._renderRowData(r,n,e[i]);this._appendChildren(o,s);n++;t.push(o)}else if(e[i].children&&(e[i].open!="false"&&e[i].open!=false)){t.push(o);var a=this.buildRows(e[i].children,r,n);t=t.concat(a.rows);n=a.rowNumber}else{t.push(o);var l=this._renderAggregateRowData(r,n,e[i]);n++;t=t.concat(l)}}return{rows:t,rowNumber:n}},_renderGlobalRow:function(e,r,n){},_renderAggregateRowData:function(e,r,n){var t=new Array,i=new Array,o=this.renderer.renderRowContainer(),s=this.getColumnsNumbersFromObjects(e);for(var a=0;a-1){t.push(i[o])}else if(i[o].children&&(i[o].open==true||i[o].open=="true")){var s=this.getNodeFromProperty(e,r,i[o].children);if(s)t=t.concat(s)}else continue}return t},getObjectsGrouped:function(e){var r=[];if(typeof e==undefined)return[];else{for(var n in e){if((e[n].open==false||e[n].open=="false")&&e[n].children){r.push({group:this._getObjectsFromTree(e[n].children)})}else if(e[n].children){var t=this.getObjectsGrouped(e[n].children);if(t)r=r.concat(t)}else if(e[n].summary){r.push({summary:e[n].object})}else if(e[n].object!=undefined){r.push({object:[e[n].object]})}}}if(r.length==0)return;return r},_getObjectsFromTree:function(e,r){var n=new Array;for(var t in e){if(r==true&&e[t].summary&&e[t].object)n=n.concat(e[t].object);else if(e[t].object&&!e[t].summary)n.push(e[t].object);if(e[t].children)n=n.concat(this._getObjectsFromTree(e[t].children,r))}return n},onResize:function(){},beforeCellClick:function(){},onCellClick:function(e,r,n){console.log(e,r);console.log(this.getRowsObjects(e,true),this.getColumnsObjects(r,true));if(this.controller.onCellClick){this.controller.onCellClick(n,this.dataprovider.getData(this.getRowsObjects(e,true),this.getColumnsObjects(r,true)),this.getRowsObjects(e,true),this.getColumnsObjects(r,true))}},onCellHover:function(e,r,n){if(this.controller.onCellHover)this.controller.onCellHover(n)},onCellOut:function(e,r,n){if(this.controller.onCellOut)this.controller.onCellOut(n)},onCellRightClick:function(){},onCellDoubleClick:function(){},onHeaderClick:function(e,r){if(this.controller.onHeaderClick)this.controller.onHeaderClick(r,e)},onHeaderHover:function(e){if(this.controller.onHeaderHover)this.controller.onHeaderHover(e)},onHeaderOut:function(e){if(this.controller.onHeaderOut)this.controller.onHeaderOut(e)},onHeaderRightClick:function(){},onHeaderDoubleClick:function(){},graphicalRowFilter:function(e){},dataRowFilter:function(e){},graphicalColumnFilter:function(e){},dataColumnFilter:function(e){},graphicalCellFilter:function(e){},dataCellFilter:function(e){},set:function(e,r){this[e]=r;return this},toggleHeader:function(e){if(e.open==false||e.open=="false"){e.open=true}else{e.open=false}},toggleHeaderVisibility:function(e){if(e.hidden==false||e.hidden=="false"){e.hidden=true}else{e.hidden=false}},refresh:function(e){var r=new Date;this.renderer.clearOutput(this.workspace);this.container=this.renderer.renderContainer();if(e=="columnHeader"){var n=this._preRenderColumns(null,{reset:true});this.columns=n}else if(e=="rowHeader"){var t=this._preRenderRows(null,{reset:true});this.rows=t}if(this.columns)this.displayColumns(this.columns,this.rows.depth);console.log("appendColumns : "+(new Date-r));if(this.columns)this.displayData(this.rows,this.getObjectsGrouped(this.columns.rendering));else this.displayData(this.rows);console.log("get columns by group");console.log("appendData & pre-display : "+(new Date-r));this._appendChild(this.workspace,this.container);console.log("displayed : "+(new Date-r));console.log(this.rows,this.columns)}};r=Class.create(r);e.Core=r;e.extend=Class.extend;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(e){},onCellHover:function(e,r){},onCellClick:function(e,r){},onCellOut:function(e,r){},onHeaderHover:function(e,r){},onHeaderOut:function(e,r){},onHeaderClick:function(e,r){},onGraphicalRowFilter:function(e){}};r=Class.create(r);e.IIJController=r;e.extend=Class.extend;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){},aggregateData:function(e,r,n){}};r=Class.create(r);e.Aggregator=r;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){},getData:function(){},getRows:function(){},getColumns:function(){},getIntersection:function(e,r){},getParentId:function(e){},getId:function(e){}};r=Class.create(r);e.IIJDataProvider=r;return e}(enioka.ij||{});var enioka=enioka||{};enioka.ij=function(e){var r={initialize:function(){},addClasses:function(e,r,n){if(n)e.className="";if(r)for(var t=0;t j) { + renderedObjects[i][j].children = new Array(); + if (renderedObjects[i][j].object) { + renderedObjects[i][j].children.push(this._cloneHeader(renderedObjects[i][j], type)); + delete renderedObjects[i][j].object; + } + if (renderedObjects[i][j].hasSummary) { + var summary = this.renderer.renderSummary(renderedObjects[i][j], type); + summary.summary = true; + renderedObjects[i][j].children.push(summary); + } + } + map[currentID] = renderedObjects[i][j]; + } else { + if (j > 0) { + var found = false; + for (var k in parentRoot) { + if (parentRoot[k].id && parentRoot[k].id == renderedObjects[i][j].id) { + found = true; + break; + } + } + if (found != true) { + var id = renderedObjects[i][j].id; + var tmpRoot = map[currentID]; + this._deleteNode(id, _scope.root); + parentRoot.push(tmpRoot); + delete map[currentID]; + map[currentID] = tmpRoot; + } + } + if (renderedObjects[i].length - 1 > j) { + if (!map[currentID].children) { + map[currentID].children = new Array(); + if (map[currentID].object) { + map[currentID].children.push(this._cloneHeader(renderedObjects[i][j], type)); + map[currentID].children[0].object = map[currentID].object; + delete map[currentID].object; + } + } + } + } + parentRoot = map[currentID].children; + } + } + return _scope.root; + }, + _deleteNode: function(nodeId, node) { + for (var id in node) { + if (node[id].id == nodeId) delete node[id]; else if (node[id].children) this._deleteNode(nodeId, node[id].children); + } + }, + _cloneHeader: function(header, type) { + var duplicatedHeader = {}; + for (var attr in header) { + if (attr == "label") duplicatedHeader[attr] = header[attr] + " [object]"; else if (attr == "children") continue; else if (attr == "order") duplicatedHeader[attr] = -1; else if (attr == "id") { + duplicatedHeader[attr] = header[attr] + "_child"; + } else if (attr == "rendering") { + duplicatedHeader[attr] = this.renderer.setId(header[attr], this.renderer.getIdPrefix(type) + duplicatedHeader.id); + } else duplicatedHeader[attr] = header[attr]; + } + duplicatedHeader.type = type; + return duplicatedHeader; + }, + orderRenderedTree: function(renderedTree) { + var start = new Date(); + var ordered = new Array(), root = new Array(); + for (var id in renderedTree) { + if (!ordered[renderedTree[id].order]) ordered[renderedTree[id].order] = new Array(); + ordered[renderedTree[id].order].push(renderedTree[id]); + if (renderedTree[id].children) renderedTree[id].children = this.orderRenderedTree(renderedTree[id].children); + } + if (ordered["-1"]) root = root.concat(this.alphabeticalSort(ordered["-1"])); + for (var id in ordered) { + if (id != -1) root = root.concat(this.alphabeticalSort(ordered[id])); + } + return root; + }, + alphabeticalSort: function(array) { + if (this.sort) return array.sort(function compare(a, b) { + if (a.label < b.label) return -1; + if (a.label > b.label) return 1; + return 0; + }); else return array; + }, + getTreeDepth: function(renderedObjectTree) { + var depth = 0; + for (var id in renderedObjectTree) { + if (renderedObjectTree[id].children) { + var childrenDepth = this.getTreeDepth(renderedObjectTree[id].children); + renderedObjectTree[id].group = true; + if (childrenDepth > depth) depth = childrenDepth; + } + } + return depth + 1; + }, + applyTreeDepth: function(renderedObjectTree, depth) { + var start = new Date(); + for (var id in renderedObjectTree) { + if (renderedObjectTree[id].children && renderedObjectTree[id].open == true) { + renderedObjectTree[id].depth = 1; + renderedObjectTree[id].children = this.applyTreeDepth(renderedObjectTree[id].children, depth - 1); + } else { + renderedObjectTree[id].depth = depth; + } + } + return renderedObjectTree; + }, + populateSummaries: function(treeNode) { + for (var id in treeNode) { + if (treeNode[id].hasSummary && treeNode[id].open == true) { + treeNode[id].children[treeNode[id].children.length - 1].object = new Array(); + var objects = this._getObjectsFromTree(treeNode[id].children, false); + treeNode[id].children[treeNode[id].children.length - 1].object = objects; + } + if (treeNode[id].children && treeNode[id].open == true) this.populateSummaries(treeNode[id].children); + } + }, + _preRenderColumns: function(columns, properties) { + console.profile("_preRenderColumns"); + if (columns) { + var renderedColumns = this.getRenderedColumns(columns); + var renderedColumns = this.buildRenderedTree(renderedColumns, "columnHeader"); + renderedColumns = this.orderRenderedTree(renderedColumns); + } else if (this.columns && this.columns.rendering) { + var renderedColumns = this.columns.rendering; + } else { + return; + } + for (var id in renderedColumns) { + renderedColumns[id] = this.getGroupSpan(renderedColumns[id]).renderedTreeNode; + } + if (!this.hideSummaries) this.populateSummaries(renderedColumns); + var columnsDepth = this.getTreeDepth(renderedColumns); + this.applyTreeDepth(renderedColumns, columnsDepth); + this.applyOnRenderedObjects(renderedColumns, this.renderer.applyColSpan.bind(this.renderer), "span"); + this.applyOnRenderedObjects(renderedColumns, this.renderer.applyRowSpan.bind(this.renderer), "depth"); + this.applyClasses(renderedColumns, this.renderer.addClasses.bind(this.renderer), null, properties); + console.profileEnd(); + return { + depth: columnsDepth, + rendering: renderedColumns + }; + }, + displayColumns: function(columns, rowsDepth) { + var columnsContainer = this.renderer.renderColumnsContainer(); + var columnsLevels = this.buildColumns(columns.rendering); + var leftUpperCorner = { + rendering: this.renderer.renderLeftUpperCorner(), + colspan: rowsDepth || 1, + rowspan: columns.depth || 1 + }; + leftUpperCorner.rendering = this.renderer.applyColSpan(leftUpperCorner.rendering, leftUpperCorner["colspan"]); + leftUpperCorner.rendering = this.renderer.applyRowSpan(leftUpperCorner.rendering, leftUpperCorner["rowspan"]); + if (columns.rendering.length > 0) columnsLevels[1].unshift(leftUpperCorner.rendering); + for (var lvl in columnsLevels) { + var level = this.renderer.renderColumnsLevelContainer(); + for (var col in columnsLevels[lvl]) { + level = this._appendChild(level, columnsLevels[lvl][col]); + } + columnsContainer = this._appendChild(columnsContainer, level); + } + this.container = this._appendChild(this.container, columnsContainer); + }, + buildColumns: function(renderedColumns, level) { + level = typeof level !== "undefined" ? level : 1; + var columnsLevel = new Array(); + columnsLevel[level] = new Array(); + for (var id in renderedColumns) { + renderedColumns[id] = this.renderer.reRenderColumn(renderedColumns[id], this._getHeaderEventsCallbacks(renderedColumns[id])); + columnsLevel[level].push(renderedColumns[id].rendering); + if (renderedColumns[id].children && (renderedColumns[id].open != false && renderedColumns[id].open != "false")) { + var childrenArray = this.buildColumns(renderedColumns[id].children, level + 1); + for (var lvl in childrenArray) { + if (!columnsLevel[lvl]) columnsLevel[lvl] = new Array(); + for (var val in childrenArray[lvl]) { + columnsLevel[lvl].push(childrenArray[lvl][val]); + } + } + } + } + return columnsLevel; + }, + _preRenderRows: function(rows, properties) { + console.profile("rows"); + if (rows) { + var renderedRows = this.buildRenderedTree(this.getRenderedRows(rows), "rowHeader"); + renderedRows = this.orderRenderedTree(renderedRows); + } else if (this.rows && this.rows.rendering) { + var renderedRows = this.rows.rendering; + } else { + return; + } + for (var id in renderedRows) { + renderedRows[id] = this.getGroupSpan(renderedRows[id], 1).renderedTreeNode; + } + if (!this.hideSummaries) this.populateSummaries(renderedRows); + var rowsDepth = this.getTreeDepth(renderedRows); + this.applyTreeDepth(renderedRows, rowsDepth); + this.applyOnRenderedObjects(renderedRows, this.renderer.applyRowSpan.bind(this.renderer), "span"); + this.applyOnRenderedObjects(renderedRows, this.renderer.applyColSpan.bind(this.renderer), "depth"); + this.applyClasses(renderedRows, this.renderer.addClasses.bind(this.renderer), null, properties); + console.profileEnd(); + return { + depth: rowsDepth, + rendering: renderedRows + }; + }, + displayData: function(rows, columns) { + if (!this.container) this.container = this.renderer.renderContainer(); + var rowsContainer = this.renderer.renderRowsContainer(); + if (rows && columns) rows = this.buildRows(rows.rendering, columns).rows; else if (rows) rows = this.buildRows(rows.rendering, null).rows; else rows = this.buildMatrix(); + for (var row in rows) { + rowsContainer = this._appendChild(rowsContainer, rows[row]); + } + this.container = this._appendChild(this.container, rowsContainer); + }, + buildMatrix: function() { + var matrix = this.dataprovider.getData(), rows = new Array(), rowContainer, cells; + console.log(matrix); + for (var i = 0; i < matrix.length; i++) { + cells = new Array(); + rowContainer = this.renderer.renderRowContainer(); + for (var j = 0; j < matrix[i].length; j++) { + cells.push(this.renderer.renderCell([ i ], [ j ], matrix[i][j], this._getCellEventsCallbacks([ i ], [ j ]))); + } + this._appendChildren(rowContainer, cells); + rows.push(rowContainer); + } + return rows; + }, + applyOnRenderedObjects: function(renderedObjects, callback, params) { + for (var id in renderedObjects) { + renderedObjects[id].rendering = callback(renderedObjects[id].rendering, renderedObjects[id][params]); + if (renderedObjects[id].children) renderedObjects[id].children = this.applyOnRenderedObjects(renderedObjects[id].children, callback, params); + } + return renderedObjects; + }, + applyClasses: function(renderedObjects, callback, currentId, properties) { + if (!currentId) var currentId = 0; + for (var id in renderedObjects) { + var classes = new Array(); + if (renderedObjects[id].children) { + this.applyClasses(renderedObjects[id].children, callback, currentId, properties); + if (renderedObjects[id].group == true && renderedObjects[id].open == false) var nextId = currentId + 1; else var nextId = currentId + this.getObjectsGrouped(renderedObjects[id].children).length; + for (var i = currentId; i < nextId; i++) { + classes.push(i); + } + } else if (renderedObjects[id].object != undefined) { + var nextId = currentId + 1; + for (var i = currentId; i < nextId; i++) { + classes.push(i); + } + } + currentId = nextId; + renderedObjects[id].rendering = callback(renderedObjects[id].rendering, renderedObjects[id].type, classes, properties); + } + return renderedObjects; + }, + buildRows: function(rowsTreeNode, columns, rowNumber) { + if (!rowNumber) var rowNumber = 0; + var rows = new Array(); + if (rowsTreeNode.length > 0) for (var id in rowsTreeNode) { + var row = this.renderer.renderRowContainer(); + if (rowsTreeNode[id].children && (rowsTreeNode[id].open == "false" || rowsTreeNode[id].open == false)) { + rowsTreeNode[id].rendering = this.renderer.applyRowSpan(rowsTreeNode[id].rendering, 2); + } + rowsTreeNode[id] = this.renderer.reRenderRow(rowsTreeNode[id], this._getHeaderEventsCallbacks(rowsTreeNode[id])); + row = this._appendChild(row, rowsTreeNode[id].rendering); + if (rowsTreeNode[id].summary) { + var rowData = this._renderRowSummary(columns, rowNumber, rowsTreeNode[id]); + row = this._appendChildren(row, rowData); + rowNumber++; + rows.push(row); + } else if (rowsTreeNode[id].object) { + var rowData = this._renderRowData(columns, rowNumber, rowsTreeNode[id]); + row = this._appendChildren(row, rowData); + rowNumber++; + rows.push(row); + } else if (rowsTreeNode[id].children && (rowsTreeNode[id].open != "false" && rowsTreeNode[id].open != false)) { + rows.push(row); + var builtRows = this.buildRows(rowsTreeNode[id].children, columns, rowNumber); + rows = rows.concat(builtRows.rows); + rowNumber = builtRows.rowNumber; + } else { + rows.push(row); + var rowsData = this._renderAggregateRowData(columns, rowNumber, rowsTreeNode[id]); + rowNumber++; + rows = rows.concat(rowsData); + } + } + return { + rows: rows, + rowNumber: rowNumber + }; + }, + _renderAggregateRowData: function(columns, rowNumber, rowsTreeNode) { + var rows = new Array(), cells = new Array(), row = this.renderer.renderRowContainer(), columnsNumbers = this.getColumnsNumbersFromObjects(columns); + for (var i = 0; i < columnsNumbers.length; i++) { + var cellData = this.dataprovider.getData(this._getObjectsFromTree(rowsTreeNode.children, false), columns[i].object || columns[i].summary || columns[i].group, null, { + group: true + }); + cells.push(this.renderer.renderCell([ rowNumber ], columnsNumbers[i], cellData, this._getCellEventsCallbacks([ rowNumber ], columnsNumbers[i]))); + } + row = this._appendChildren(row, cells); + return rows; + }, + _renderRowData: function(columns, rowNumber, renderedRow) { + var columnsNumbers = this.getColumnsNumbersFromObjects(columns), cells = new Array(), rowsNumbers = [ rowNumber ]; + for (var i = 0; i < columnsNumbers.length; i++) { + var cellData = this.dataprovider.getData([ renderedRow.object ], columns[i].object || columns[i].summary || columns[i].group); + cells.push(this.renderer.renderCell(rowsNumbers, columnsNumbers[i], cellData, this._getCellEventsCallbacks(rowsNumbers, columnsNumbers[i]))); + } + return cells; + }, + _renderRowSummary: function(columns, rowNumber, rowsTreeNode) { + var columnsNumbers = this.getColumnsNumbersFromObjects(columns), cells = new Array(), rowsNumbers = new Array(); + rowsNumbers.push(rowNumber); + for (var i = 0; i < columnsNumbers.length; i++) { + var cellData = this.dataprovider.getData(rowsTreeNode.object, columns[i].object || columns[i].summary || columns[i].group, null, { + summary: true + }); + cells.push(this.renderer.renderCell(rowsNumbers, columnsNumbers[i], cellData, this._getCellEventsCallbacks(rowsNumbers, columnsNumbers[i]))); + } + console.log(cells); + return cells; + }, + _appendChild: function(element, child) { + return this.renderer.appendChild(element, child); + }, + _appendChildren: function(element, children) { + for (var i = 0; i < children.length; i++) { + element = this._appendChild(element, children[i]); + } + return element; + }, + getGroupSpan: function(renderedTreeNode, span) { + if (!span) span = 0; + if (renderedTreeNode.children && renderedTreeNode.open != "false" && renderedTreeNode.open != false) { + var initialSpan = span; + for (var id in renderedTreeNode.children) { + span += this.getGroupSpan(renderedTreeNode.children[id], initialSpan).span; + } + } else if (renderedTreeNode.children && renderedTreeNode.type == "rowHeader") { + span = 2; + } else { + span = 1; + } + renderedTreeNode.span = span; + return { + renderedTreeNode: renderedTreeNode, + span: span + }; + }, + display: function() { + if (!this.container) this.container = this.renderer.renderContainer(); + var start = new Date(); + var columns = this._preRenderColumns(this.dataprovider.getColumns()); + console.log("column pre-render : " + (new Date() - start)); + console.log("columns", columns); + var rows = this._preRenderRows(this.dataprovider.getRows()); + if (rows) this.rows = rows; + console.log("rows pre-render : " + (new Date() - start)); + console.log("rows : ", rows); + if (columns) { + this.columns = columns; + this.displayColumns(columns, rows.depth); + console.log("appendColumns : " + (new Date() - start)); + this.displayData(rows, this.getObjectsGrouped(columns.rendering)); + } else this.displayData(rows); + console.log("appendData & pre-display : " + (new Date() - start)); + console.log(this.container); + this.workspace = this._appendChild(this.workspace, this.container); + console.log("displayed : " + (new Date() - start)); + console.log("rows & columns structures :"); + console.log(rows, columns); + }, + _getCellEventsCallbacks: function(rowsNumbers, columnsNumbers) { + return { + mouseover: this.onCellHover.bind(this, rowsNumbers, columnsNumbers), + mouseout: this.onCellOut.bind(this, rowsNumbers, columnsNumbers), + click: this.onCellClick.bind(this, rowsNumbers, columnsNumbers) + }; + }, + _getHeaderEventsCallbacks: function(treeNode) { + return { + mouseover: this.onHeaderHover.bind(this, treeNode), + mouseout: this.onHeaderOut.bind(this, treeNode), + click: this.onHeaderClick.bind(this, treeNode) + }; + }, + update: function() {}, + exportToCSV: function() {}, + exportMatrix: function() {}, + getHeaderType: function(headerNode) { + return headerNode.type; + }, + getRowObject: function(number, summary) { + var object = this.getObjectsGrouped(this.rows.rendering)[number]; + return object.object || object.summary || object.group; + }, + getRowsObjects: function(numbers, summary) { + var rowsObjects = new Array(); + for (var i = 0; i < numbers.length; i++) { + var objects = this.getRowObject(numbers[i], summary); + if (objects instanceof Array) rowsObjects = rowsObjects.concat(objects); else rowsObjects.push(objects); + } + return rowsObjects; + }, + getColumnObject: function(number, summary) { + var object = this.getObjectsGrouped(this.columns.rendering)[number]; + return object.object || object.summary || object.group; + }, + getColumnsObjects: function(numbers, summary) { + var columnsObjects = new Array(); + for (var i = 0; i < numbers.length; i++) { + var objects = this.getColumnObject(numbers[i], summary); + if (objects instanceof Array) columnsObjects = columnsObjects.concat(objects); else columnsObjects.push(objects); + } + return columnsObjects; + }, + getRowNumber: function(object) { + if (!this.rowsObjects) { + this.rowsObjects = this._getObjectsFromTree(this.rows.rendering, true); + } + for (var i = 0; i < this.rowsObjects.length; i++) { + if (JSON.stringify(this.rowsObjects[i]) == JSON.stringify(object)) return i; + } + return -1; + }, + getColumnNumber: function(object) { + if (!this.columnsObjects) { + this.columnsObjects = this._getObjectsFromTree(this.columns.rendering, true); + } + for (var i = 0; i < this.columnsObjects.length; i++) { + if (JSON.stringify(this.columnsObjects[i]) == JSON.stringify(object)) return i; + } + return -1; + }, + getColumnsNumbersFromObjects: function(columnsObjects) { + var numbers = new Array(), lastNumber = 0, map; + for (var i = 0; i < columnsObjects.length; i++) { + numbers[i] = new Array(); + numbers[i].push(i); + } + return numbers; + }, + getAllRowsObjects: function() { + if (!this.rowsObjects) { + this.rowsObjects = this._getObjectsFromTree(this.rows.rendering, true); + } + return this.rowsObjects; + }, + getAllColumnsObjects: function() { + if (!this.columnsObjects) { + this.columnsObjects = this._getObjectsFromTree(this.columns.rendering, true); + } + return this.columnsObjects; + }, + getRowsNumber: function() { + if (!this.rowsObjects) { + this.rowsObjects = this._getObjectsFromTree(this.rows.rendering, true); + } + return this.rowsObjects; + }, + getColumnsNumber: function() { + if (!this.columnsObjects) { + this.columnsObjects = this._getObjectsFromTree(this.columns.rendering, true); + } + return this.columnsObjects.length; + }, + getNodeFromProperty: function(property, value, from) { + var node = null; + for (var id in from) { + if (from[id][property] == value) { + node = from[id]; + } else if (from[id].children) { + node = this.getNodeFromProperty(property, value, from[id].children); + } + if (node != null) break; + } + return node; + }, + matchNodesFromProperty: function(property, value, type) { + var node = new Array(); + if (type == "rowHeader") { + if (!this.rows) return []; + var from = this.rows.rendering; + } else if (type == "columnHeader") { + if (!this.columns) return []; + var from = this.columns.rendering; + } else return; + for (var id in from) { + if (from[id][property].indexOf(value) > -1) { + node.push(from[id]); + } else if (from[id].children && (from[id].open == true || from[id].open == "true")) { + var returned = this.getNodeFromProperty(property, value, from[id].children); + if (returned) node = node.concat(returned); + } else continue; + } + return node; + }, + getObjectsGrouped: function(renderedObjectsTree) { + var objects = []; + if (typeof renderedObjectsTree == undefined) return []; else { + for (var id in renderedObjectsTree) { + if ((renderedObjectsTree[id].open == false || renderedObjectsTree[id].open == "false") && renderedObjectsTree[id].children) { + objects.push({ + group: this._getObjectsFromTree(renderedObjectsTree[id].children) + }); + } else if (renderedObjectsTree[id].children) { + var childrenObjects = this.getObjectsGrouped(renderedObjectsTree[id].children); + if (childrenObjects) objects = objects.concat(childrenObjects); + } else if (renderedObjectsTree[id].summary) { + objects.push({ + summary: renderedObjectsTree[id].object + }); + } else if (renderedObjectsTree[id].object != undefined) { + objects.push({ + object: [ renderedObjectsTree[id].object ] + }); + } + } + } + if (objects.length == 0) return; + return objects; + }, + _getObjectsFromTree: function(renderedObjectsTree, summary) { + var objects = new Array(); + for (var id in renderedObjectsTree) { + if (summary == true && renderedObjectsTree[id].summary && renderedObjectsTree[id].object) objects = objects.concat(renderedObjectsTree[id].object); else if (renderedObjectsTree[id].object && !renderedObjectsTree[id].summary) objects.push(renderedObjectsTree[id].object); + if (renderedObjectsTree[id].children) objects = objects.concat(this._getObjectsFromTree(renderedObjectsTree[id].children, summary)); + } + return objects; + }, + onResize: function() {}, + beforeCellClick: function() {}, + onCellClick: function(rowsNumbers, columnsNumbers, event) { + console.log(rowsNumbers, columnsNumbers); + console.log(this.getRowsObjects(rowsNumbers, true), this.getColumnsObjects(columnsNumbers, true)); + if (this.controller.onCellClick) { + this.controller.onCellClick(event, this.dataprovider.getData(this.getRowsObjects(rowsNumbers, true), this.getColumnsObjects(columnsNumbers, true)), this.getRowsObjects(rowsNumbers, true), this.getColumnsObjects(columnsNumbers, true)); + } + }, + onCellHover: function(rowsNumbers, columnsNumbers, event) { + if (this.controller.onCellHover) this.controller.onCellHover(event); + }, + onCellOut: function(rowsNumbers, columnsNumbers, event) { + if (this.controller.onCellOut) this.controller.onCellOut(event); + }, + onCellRightClick: function() {}, + onCellDoubleClick: function() {}, + onHeaderClick: function(headerNode, event) { + if (this.controller.onHeaderClick) this.controller.onHeaderClick(event, headerNode); + }, + onHeaderHover: function(event) { + if (this.controller.onHeaderHover) this.controller.onHeaderHover(event); + }, + onHeaderOut: function(event) { + if (this.controller.onHeaderOut) this.controller.onHeaderOut(event); + }, + onHeaderRightClick: function() {}, + onHeaderDoubleClick: function() {}, + graphicalRowFilter: function(filter) {}, + dataRowFilter: function(filter) {}, + graphicalColumnFilter: function(filter) {}, + dataColumnFilter: function(filter) {}, + graphicalCellFilter: function(filter) {}, + dataCellFilter: function(filter) {}, + set: function(propertyName, propertyValue) { + this[propertyName] = propertyValue; + return this; + }, + toggleHeader: function(headerNode) { + if (headerNode.open == false || headerNode.open == "false") { + headerNode.open = true; + } else { + headerNode.open = false; + } + }, + toggleHeaderVisibility: function(headerNode) { + if (headerNode.hidden == false || headerNode.hidden == "false") { + headerNode.hidden = true; + } else { + headerNode.hidden = false; + } + }, + refresh: function(type) { + var start = new Date(); + this.renderer.clearOutput(this.workspace); + this.container = this.renderer.renderContainer(); + if (type == "columnHeader") { + var columns = this._preRenderColumns(null, { + reset: true + }); + this.columns = columns; + } else if (type == "rowHeader") { + var rows = this._preRenderRows(null, { + reset: true + }); + this.rows = rows; + } + if (this.columns) this.displayColumns(this.columns, this.rows.depth); + console.log("appendColumns : " + (new Date() - start)); + if (this.columns) this.displayData(this.rows, this.getObjectsGrouped(this.columns.rendering)); else this.displayData(this.rows); + console.log("get columns by group"); + console.log("appendData & pre-display : " + (new Date() - start)); + this.workspace = this._appendChild(this.workspace, this.container); + console.log("displayed : " + (new Date() - start)); + console.log(this.rows, this.columns); + } + }; + Core = Class.create(Core); + eniokaij.Core = Core; + eniokaij.extend = Class.extend; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var IIJController = { + initialize: function(core) {}, + onCellHover: function(event, cellData) {}, + onCellClick: function(event, cellData) {}, + onCellOut: function(event, cellData) {}, + onHeaderHover: function(event, headerNode) {}, + onHeaderOut: function(event, headerNode) {}, + onHeaderClick: function(event, headerNode) {}, + onGraphicalRowFilter: function(filter) {} + }; + IIJController = Class.create(IIJController); + eniokaij.IIJController = IIJController; + eniokaij.extend = Class.extend; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var Aggregator = { + initialize: function() {}, + aggregateData: function(rowsObjects, columnsObjects, filter) {} + }; + Aggregator = Class.create(Aggregator); + eniokaij.Aggregator = Aggregator; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var IIJDataProvider = { + initialize: function() {}, + getData: function() {}, + getRows: function() {}, + getColumns: function() {}, + getIntersection: function(row, column) {}, + getParentId: function(object) {}, + getId: function(object) {} + }; + IIJDataProvider = Class.create(IIJDataProvider); + eniokaij.IIJDataProvider = IIJDataProvider; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var HTMLRenderer = { + initialize: function() {}, + addClasses: function(element, classes, reset) { + if (reset) element.className = ""; + if (classes) for (var i = 0; i < classes.length; i++) { + element.classList.add(classes[i]); + } + return element; + }, + addAttribute: function(element, attributeName, attributeValue) { + element.setAttribute(attributeName, attributeValue); + return element; + }, + addCSS: function(element, attributeName, attributeValue) { + element.style[attributeName] = attributeValue; + return element; + }, + createElementWithText: function(element, text, classes) { + var htmlElement = this.createElement(element, classes), htmlText = document.createTextNode(text); + htmlElement.appendChild(htmlText); + return htmlElement; + }, + createElement: function(element, classes) { + var htmlElement = document.createElement(element); + if (classes) this.addClasses(htmlElement, classes); + return htmlElement; + }, + appendChild: function(element, child, prepend) { + var children = new Array(); + if (prepend) { + while (element.firstChild) { + children.push(element.firstChild); + element.removeChild(element.firstChild); + } + element.appendChild(child); + for (var i = 0; i < children.length; i++) { + element.appendChild(children[i]); + } + return element; + } + return element.appendChild(child); + } + }; + HTMLRenderer = Class.create(HTMLRenderer); + eniokaij.HTMLRenderer = HTMLRenderer; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var HTMLTemplate = { + initialize: function() { + this.template = {}; + }, + addClassPrefix: function(elementType, classPrefix) { + if (!this.template[elementType]) this.template[elementType] = {}; + this.template[elementType].classPrefix = classPrefix; + }, + addIdPrefix: function(elementType, idPrefix) { + if (!this.template[elementType]) this.template[elementType] = {}; + this.template[elementType].idPrefix = idPrefix; + }, + getAttribute: function(elementType, propertyName) { + if (this.template[elementType]) return this.template[elementType][propertyName]; else return null; + } + }; + HTMLTemplate = Class.create(HTMLTemplate); + eniokaij.HTMLTemplate = HTMLTemplate; + return eniokaij; +}(enioka.ij || {}); + +var enioka = enioka || {}; + +enioka.ij = function(eniokaij) { + var IIJRenderer = { + initialize: function() { + this.renderer = new enioka.ij.HTMLRenderer(); + this.template = new enioka.ij.HTMLTemplate(); + }, + renderRowsContainer: function() {}, + renderRow: function(rowObject) {}, + applyRowSpan: function(renderedObject, property) {}, + applyColSpan: function(renderedObject, property) {}, + renderRowContainer: function() {}, + renderSubTotalHeader: function(label) {}, + renderColumn: function(columnObject) {}, + renderLeftUpperCorner: function() {}, + renderColumnsLevelContainer: function() {}, + renderColumnsContainer: function() {}, + renderCell: function(row, column, cellData) {}, + renderContainer: function() {}, + setCSSProperty: function(property, element, propertyValue) {}, + emptyCSSProperty: function(property, element) {}, + addClasses: function(element, elementType, classes) {}, + getRenderingId: function(rendering) { + return rendering.id; + }, + getRenderingClasses: function(rendering) { + return rendering.classList; + }, + renderRowsContainer: function() {}, + renderRow: function(rowObject, rowNumber) {}, + applyRowSpan: function(renderedObject, property) {}, + applyColSpan: function(renderedObject, property) {}, + renderRowContainer: function() {}, + renderSubTotalHeader: function(label) {}, + renderColumn: function(columnObject, columnNumber) {}, + renderLeftUpperCorner: function() {}, + renderColumnsLevelContainer: function() {}, + renderColumnsContainer: function() {}, + renderSummary: function(renderedObject) {}, + renderCell: function(rowsNumbers, columnsNumbers, cellData, eventsCallBacks) {}, + _getSummaryHoverCell: function(cellData) {}, + appendChild: function(element, child) {}, + renderContainer: function() {}, + setCSSProperty: function(property, element, propertyValue) {}, + emptyCSSProperty: function(property, element) {}, + addClasses: function(element, elementType, classes) {}, + setId: function(element, id) {}, + getClassPrefix: function(type) {}, + getIdPrefix: function(type) {}, + addEventsToRendering: function(rendering, events) {}, + clearOutput: function(output) {} + }; + IIJRenderer = Class.create(IIJRenderer); + eniokaij.IIJRenderer = IIJRenderer; + return eniokaij; +}(enioka.ij || {}); \ No newline at end of file diff --git a/src/js/ij.Core.js b/src/js/ij.Core.js index 8e1d54b..80f832e 100644 --- a/src/js/ij.Core.js +++ b/src/js/ij.Core.js @@ -496,15 +496,15 @@ enioka.ij = ( for (var lvl in columnsLevels) { var level = this.renderer.renderColumnsLevelContainer(); for (var col in columnsLevels[lvl]) { - this._appendChild(level, + level = this._appendChild(level, columnsLevels[lvl][col] ); } - this._appendChild( + columnsContainer = this._appendChild( columnsContainer, level); } - this._appendChild(this.container, columnsContainer); + this.container = this._appendChild(this.container, columnsContainer); }, /** @@ -605,9 +605,9 @@ enioka.ij = ( else rows = this.buildMatrix(); for (var row in rows) { - this._appendChild(rowsContainer, rows[row]); + rowsContainer = this._appendChild(rowsContainer, rows[row]); } - this._appendChild(this.container, rowsContainer); + this.container = this._appendChild(this.container, rowsContainer); }, buildMatrix: function () { @@ -719,19 +719,19 @@ enioka.ij = ( rowsTreeNode[id] ) ); - this._appendChild(row, rowsTreeNode[id].rendering); + row = this._appendChild(row, rowsTreeNode[id].rendering); if (rowsTreeNode[id].summary){ var rowData = this._renderRowSummary(columns, rowNumber, rowsTreeNode[id]); - this._appendChildren(row, rowData); + row = this._appendChildren(row, rowData); rowNumber++; rows.push(row); } else if (rowsTreeNode[id].object) { var rowData = this._renderRowData(columns, rowNumber, rowsTreeNode[id]); - this._appendChildren(row, rowData); + row = this._appendChildren(row, rowData); rowNumber++; rows.push(row); } else if (rowsTreeNode[id].children && @@ -758,10 +758,6 @@ enioka.ij = ( }; }, - _renderGlobalRow: function(columns, rowsNumbers, rowsTreeNode){ - - }, - /** * @function * @description @@ -785,8 +781,7 @@ enioka.ij = ( [rowNumber], columnsNumbers[i]))); } - this._appendChildren(row, cells); - rows.push(row); + row = this._appendChildren(row, cells); return rows; }, @@ -838,6 +833,7 @@ enioka.ij = ( rowsNumbers, columnsNumbers[i]))); } + console.log(cells); return cells; }, @@ -861,7 +857,7 @@ enioka.ij = ( */ _appendChildren: function (element, children) { for (var i = 0; i < children.length; i++) { - this._appendChild(element, children[i]); + element = this._appendChild(element, children[i]); } return element; }, @@ -925,7 +921,8 @@ enioka.ij = ( this.displayData(rows); console.log("appendData & pre-display : " + (new Date() - start)); - this._appendChild(this.workspace, this.container); + console.log(this.container); + this.workspace = this._appendChild(this.workspace, this.container); console.log("displayed : " + (new Date() - start)); console.log("rows & columns structures :"); console.log(rows, columns); @@ -1401,7 +1398,7 @@ enioka.ij = ( console.log("get columns by group"); console.log("appendData & pre-display : " + (new Date() - start)); - this._appendChild(this.workspace, this.container); + this.workspace = this._appendChild(this.workspace, this.container); console.log("displayed : " + (new Date() - start)); console.log(this.rows, this.columns);