diff --git a/KoGrid-1.2.4.debug.js b/KoGrid-1.2.4.debug.js index 7f124744..2568865e 100644 --- a/KoGrid-1.2.4.debug.js +++ b/KoGrid-1.2.4.debug.js @@ -2,7 +2,7 @@ * koGrid JavaScript Library * Authors: https://github.com/ericmbarnard/KoGrid/blob/master/README.md * License: MIT (http://www.opensource.org/licenses/mit-license.php) -* Compiled At: 11/05/2012 19:40:39 +* Compiled At: 11/05/2012 21:34:40 ***********************************************/ @@ -667,7 +667,7 @@ kg.Row = function (entity, config, selectionManager) { var element = event.target; //check and make sure its not the bubbling up of our checked 'click' event - if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) { + if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) { return true; } if (config.selectWithCheckboxOnly && element.type != "checkbox"){ @@ -827,7 +827,8 @@ kg.HeaderCell = function (col, rightHeaderGroup, grid) { }, DELAY); } else { clearTimeout(timer); //prevent single-click action - grid.resizeOnDataCallback(self.column); //perform double-click action + grid.resizeOnData(self.column); //perform double-click action + kg.cssBuilder.buildStyles(grid); clicks = 0; //after action performed, reset counter } }; @@ -976,7 +977,9 @@ kg.RowManager = function (grid) { //null the row pointer for next iteration row = null; }); - + kg.utils.forEach(grid.config.plugins, function (p) { + p.onRowsChanged(grid, rowArr); + }); self.rows(rowArr); }); @@ -2406,14 +2409,14 @@ kg.KoGrid = function (options, gridWidth) { columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW }); } } - - var createColumnSortClosure = function (col) { - return function (dir) { + + var createColumnSortClosure = function(col) { + return function(dir) { if (dir) { self.sortData(col, dir); } - } - } + }; + }; if (columnDefs.length > 0) { @@ -2467,7 +2470,9 @@ kg.KoGrid = function (options, gridWidth) { self.rows = self.rowManager.rows; // dependent observable kg.cssBuilder.buildStyles(self); - + kg.utils.forEach(self.config.plugins, function (p) { + p.onGridInit(self); + }); self.initPhase = 1; }; @@ -2490,6 +2495,9 @@ kg.KoGrid = function (options, gridWidth) { } else { h_updateTimeout = setTimeout(updater, 0); } + kg.utils.forEach(self.config.plugins, function(p) { + p.onGridUpdate(self); + }); }; this.showFilter_Click = function () { @@ -2868,7 +2876,7 @@ ko.bindingHandlers['koGrid'] = (function () { $element.addClass("kgGrid") .addClass("ui-widget") .addClass(grid.gridId.toString()); - + //make sure the templates are generated for the Grid return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext); @@ -2892,9 +2900,6 @@ ko.bindingHandlers['koGrid'] = (function () { //now use the manager to assign the event handlers kg.gridManager.assignGridEventHandlers(grid); - kg.utils.forEach(grid.config.plugins, function(p) { - p.init(grid); - }); //call update on the grid, which will refresh the dome measurements asynchronously grid.update(); diff --git a/build/KoGrid.debug.js b/build/KoGrid.debug.js index 7f124744..2568865e 100644 --- a/build/KoGrid.debug.js +++ b/build/KoGrid.debug.js @@ -2,7 +2,7 @@ * koGrid JavaScript Library * Authors: https://github.com/ericmbarnard/KoGrid/blob/master/README.md * License: MIT (http://www.opensource.org/licenses/mit-license.php) -* Compiled At: 11/05/2012 19:40:39 +* Compiled At: 11/05/2012 21:34:40 ***********************************************/ @@ -667,7 +667,7 @@ kg.Row = function (entity, config, selectionManager) { var element = event.target; //check and make sure its not the bubbling up of our checked 'click' event - if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) { + if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) { return true; } if (config.selectWithCheckboxOnly && element.type != "checkbox"){ @@ -827,7 +827,8 @@ kg.HeaderCell = function (col, rightHeaderGroup, grid) { }, DELAY); } else { clearTimeout(timer); //prevent single-click action - grid.resizeOnDataCallback(self.column); //perform double-click action + grid.resizeOnData(self.column); //perform double-click action + kg.cssBuilder.buildStyles(grid); clicks = 0; //after action performed, reset counter } }; @@ -976,7 +977,9 @@ kg.RowManager = function (grid) { //null the row pointer for next iteration row = null; }); - + kg.utils.forEach(grid.config.plugins, function (p) { + p.onRowsChanged(grid, rowArr); + }); self.rows(rowArr); }); @@ -2406,14 +2409,14 @@ kg.KoGrid = function (options, gridWidth) { columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW }); } } - - var createColumnSortClosure = function (col) { - return function (dir) { + + var createColumnSortClosure = function(col) { + return function(dir) { if (dir) { self.sortData(col, dir); } - } - } + }; + }; if (columnDefs.length > 0) { @@ -2467,7 +2470,9 @@ kg.KoGrid = function (options, gridWidth) { self.rows = self.rowManager.rows; // dependent observable kg.cssBuilder.buildStyles(self); - + kg.utils.forEach(self.config.plugins, function (p) { + p.onGridInit(self); + }); self.initPhase = 1; }; @@ -2490,6 +2495,9 @@ kg.KoGrid = function (options, gridWidth) { } else { h_updateTimeout = setTimeout(updater, 0); } + kg.utils.forEach(self.config.plugins, function(p) { + p.onGridUpdate(self); + }); }; this.showFilter_Click = function () { @@ -2868,7 +2876,7 @@ ko.bindingHandlers['koGrid'] = (function () { $element.addClass("kgGrid") .addClass("ui-widget") .addClass(grid.gridId.toString()); - + //make sure the templates are generated for the Grid return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext); @@ -2892,9 +2900,6 @@ ko.bindingHandlers['koGrid'] = (function () { //now use the manager to assign the event handlers kg.gridManager.assignGridEventHandlers(grid); - kg.utils.forEach(grid.config.plugins, function(p) { - p.init(grid); - }); //call update on the grid, which will refresh the dome measurements asynchronously grid.update(); diff --git a/plugins/koGrid-reorderable.js b/plugins/koGrid-reorderable.js index 3ec67f58..1e4c4cdc 100644 --- a/plugins/koGrid-reorderable.js +++ b/plugins/koGrid-reorderable.js @@ -7,13 +7,23 @@ self.config = $.extend(defaults, options); self.myGrid = null; - // The init method gets called during the ng-grid directive execution. - self.init = function (grid) { + // The init method gets called during the koGrid binding handler execution. + self.onGridInit = function (grid) { + /* logic */ + + }; + self.onGridUpdate = function (grid) { + /* logic */ // The directive passes in the grid scope and the grid object which we will want to save for manipulation later. self.myGrid = grid; // In this example we want to assign grid events. self.assignEvents(); }; + self.onRowsChanged = function (grid, rowCollection) { + /* logic */ + }; + + //internal funcs self.colToMove = undefined; self.rowToMove = undefined; self.assignEvents = function () { diff --git a/src/BindingHandlers/koGrid.js b/src/BindingHandlers/koGrid.js index 968fdfda..894685ce 100644 --- a/src/BindingHandlers/koGrid.js +++ b/src/BindingHandlers/koGrid.js @@ -64,7 +64,7 @@ ko.bindingHandlers['koGrid'] = (function () { $element.addClass("kgGrid") .addClass("ui-widget") .addClass(grid.gridId.toString()); - + //make sure the templates are generated for the Grid return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext); @@ -88,9 +88,6 @@ ko.bindingHandlers['koGrid'] = (function () { //now use the manager to assign the event handlers kg.gridManager.assignGridEventHandlers(grid); - kg.utils.forEach(grid.config.plugins, function(p) { - p.init(grid); - }); //call update on the grid, which will refresh the dome measurements asynchronously grid.update(); diff --git a/src/Grid.js b/src/Grid.js index 450cda36..fa7b4ae2 100644 --- a/src/Grid.js +++ b/src/Grid.js @@ -483,14 +483,14 @@ kg.KoGrid = function (options, gridWidth) { columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW }); } } - - var createColumnSortClosure = function (col) { - return function (dir) { + + var createColumnSortClosure = function(col) { + return function(dir) { if (dir) { self.sortData(col, dir); } - } - } + }; + }; if (columnDefs.length > 0) { @@ -544,7 +544,9 @@ kg.KoGrid = function (options, gridWidth) { self.rows = self.rowManager.rows; // dependent observable kg.cssBuilder.buildStyles(self); - + kg.utils.forEach(self.config.plugins, function (p) { + p.onGridInit(self); + }); self.initPhase = 1; }; @@ -567,6 +569,9 @@ kg.KoGrid = function (options, gridWidth) { } else { h_updateTimeout = setTimeout(updater, 0); } + kg.utils.forEach(self.config.plugins, function(p) { + p.onGridUpdate(self); + }); }; this.showFilter_Click = function () { diff --git a/src/GridClasses/HeaderCell.js b/src/GridClasses/HeaderCell.js index 6ab20313..5bb4d2dd 100644 --- a/src/GridClasses/HeaderCell.js +++ b/src/GridClasses/HeaderCell.js @@ -77,7 +77,8 @@ }, DELAY); } else { clearTimeout(timer); //prevent single-click action - grid.resizeOnDataCallback(self.column); //perform double-click action + grid.resizeOnData(self.column); //perform double-click action + kg.cssBuilder.buildStyles(grid); clicks = 0; //after action performed, reset counter } }; diff --git a/src/GridClasses/Row.js b/src/GridClasses/Row.js index ad08586b..48eb6c91 100644 --- a/src/GridClasses/Row.js +++ b/src/GridClasses/Row.js @@ -41,7 +41,7 @@ kg.Row = function (entity, config, selectionManager) { var element = event.target; //check and make sure its not the bubbling up of our checked 'click' event - if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) { + if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) { return true; } if (config.selectWithCheckboxOnly && element.type != "checkbox"){ diff --git a/src/GridClasses/RowManager.js b/src/GridClasses/RowManager.js index e2ac8305..88be6778 100644 --- a/src/GridClasses/RowManager.js +++ b/src/GridClasses/RowManager.js @@ -89,7 +89,9 @@ //null the row pointer for next iteration row = null; }); - + kg.utils.forEach(grid.config.plugins, function (p) { + p.onRowsChanged(grid, rowArr); + }); self.rows(rowArr); }); diff --git a/tests/RowManager_Tests.js b/tests/RowManager_Tests.js index 3fdf1795..5f0a45bb 100644 --- a/tests/RowManager_Tests.js +++ b/tests/RowManager_Tests.js @@ -60,7 +60,8 @@ kg.getTestGrid = function () { config: { rowHeight: 30, currentPage: ko.observable(1), - pageSize: ko.observable(100) + pageSize: ko.observable(100), + plugins: [] }, changeSelectedItem: function (handler) {