|
1 | 1 | /*! |
2 | | - * Angularjs grid v2.0.5 |
3 | | - * |
4 | | - * Copyright (c) 2016 Paramvir Dhindsa (http://paramquery.com) |
| 2 | + * ParamQuery Pro v3.5.0 |
| 3 | + * |
| 4 | + * Copyright (c) 2012-2021 Paramvir Dhindsa (http://paramquery.com) |
5 | 5 | * Released under GNU General Public License v3 |
6 | 6 | * http://paramquery.com/license |
7 | | - * |
| 7 | + * |
8 | 8 | */ |
| 9 | + |
9 | 10 | (function($) { |
10 | 11 | "use strict"; |
11 | | - var pq = window.pq = window.pq || {}; |
12 | 12 | if (pq.ng) { |
13 | 13 | return; |
14 | 14 | } |
|
69 | 69 | } |
70 | 70 | })() : null; |
71 | 71 | dataStr && (DM.data = $scope.$eval(dataStr)); |
72 | | - options.render = self.onRender(self, options, options.render); |
73 | | - ngM.compileHeader && (options.refreshHeader = self.onRefreshHeader(self, options.refreshHeader)); |
74 | | - ngM.compileToolbar && (options.dataAvailable = self.oneDataReady(self, 'dataAvailable')); |
75 | | - options.beforeRefreshData = self.onDataReady(self, dataStr, options.dataReady); |
76 | | - compileRows && (options.refresh = self.onRefresh(self, options.refresh)); |
77 | | - $ele.pqGrid(options).data('pqGrid'); |
78 | | - $ele.on("pqgridcellsave", self.onRefreshRowCell(self, compileRows)).on("destroy", self.onDestroy(self)); |
| 72 | + options.render = self.onRender(self, options, options.render, function(grid) { |
| 73 | + ngM.compileHeader && grid.on('refreshHeader', self.onRefreshHeader(self)); |
| 74 | + ngM.compileToolbar && grid.one('dataReady', self.oneDataReady(self)); |
| 75 | + grid.on('dataReady', self.onDataReady(self, dataStr)); |
| 76 | + compileRows && grid.on('refresh', self.onRefresh(self)); |
| 77 | + }); |
| 78 | + self.grid = pq.grid($ele, options).on("refreshRow refreshCell", self.onRefreshRowCell(self, compileRows)).on("destroy", self.onDestroy(self)); |
79 | 79 | self.bindEvents($attr); |
80 | 80 | watch === true && dataStr && self.digest($scope); |
81 | 81 | }; |
|
98 | 98 | for (key in keys) { |
99 | 99 | if (key.indexOf("on") === 0) { |
100 | 100 | eventName = key.substring(2, 3).toLowerCase() + key.substr(3); |
101 | | - self.$ele.on("pqgrid" + eventName.toLowerCase(), self.onEvent(self, $attr[key])); |
| 101 | + self.grid.on(eventName, self.onEvent(self, $attr[key])); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | }; |
|
197 | 197 | _p.onDataReady = function(self, dataStr) { |
198 | 198 | return function onDataReady(evt) { |
199 | 199 | if (dataStr) { |
200 | | - var data = self.grid.options.dataModel.data; |
| 200 | + var data = this.options.dataModel.data; |
201 | 201 | self.updateObjInt(data); |
202 | 202 | self.$parse(dataStr).assign(self.$scope, data); |
203 | 203 | }; |
|
237 | 237 | _p.onRefreshRowCell = function(self, bind) { |
238 | 238 | return function(evt, ui) { |
239 | 239 | if (bind) { |
240 | | - var $tr = self.grid.getRow(ui); |
241 | | - setTimeout(function() { |
242 | | - try { |
243 | | - self.rowScope($tr, ui.rowData, ui.rowIndx); |
244 | | - } catch (ex) {} |
245 | | - }); |
| 240 | + var $tr = this.getRow(ui); |
| 241 | + self.rowScope($tr, ui.rowData, ui.rowIndx); |
246 | 242 | } |
247 | 243 | }; |
248 | 244 | }; |
249 | 245 | _p.onRefresh = function(self) { |
250 | 246 | return function() { |
251 | | - var grid = self.grid, |
| 247 | + var grid = this, |
252 | 248 | $trs, $tr, i = 0, |
253 | 249 | len, ui, rd; |
254 | 250 | self.cleanRowScopes(); |
|
266 | 262 | }; |
267 | 263 | _p.onRefreshHeader = function(self) { |
268 | 264 | return function() { |
269 | | - var grid = self.grid, |
| 265 | + var grid = this, |
270 | 266 | $scope = self.$scope; |
271 | 267 | self.$compile(grid.$header)($scope); |
272 | 268 | self.digest($scope); |
273 | 269 | }; |
274 | 270 | }; |
275 | | - _p.oneDataReady = function(self, str) { |
| 271 | + _p.oneDataReady = function(self) { |
276 | 272 | return function() { |
277 | | - var grid = self.grid, |
| 273 | + var grid = this, |
278 | 274 | $scope = self.$scope; |
279 | | - self.$compile(grid.$toolbar)($scope); |
| 275 | + self.$compile(grid.toolbar())($scope); |
280 | 276 | self.digest($scope); |
281 | | - $(this).pqGrid('option', str, null); |
282 | 277 | }; |
283 | 278 | }; |
284 | | - _p.onRender = function(self, options, cb) { |
| 279 | + _p.onRender = function(self, options, optionsRender, cb) { |
285 | 280 | return function(evt, ui) { |
286 | | - var grid = $(this).data('paramqueryPqGrid'), |
| 281 | + var grid = this, |
287 | 282 | $scope = self.$scope; |
288 | 283 | $scope.grid = grid; |
289 | | - self.grid = grid; |
290 | 284 | grid.$scope = $scope; |
291 | 285 | options.grid = grid; |
292 | | - cb && cb.call(this, evt, ui); |
| 286 | + optionsRender && optionsRender.call(grid, evt, ui); |
| 287 | + cb(grid); |
293 | 288 | }; |
294 | 289 | }; |
295 | 290 | _p.onDestroy = function(self) { |
|
344 | 339 | column.render = self.templateCell(template); |
345 | 340 | } |
346 | 341 | if (template = column.editorTemplate) { |
347 | | - column.editor = { |
348 | | - type: self.templateEditor(self, column.editor, template, $compile, $scope) |
349 | | - }; |
| 342 | + column.editor = self.templateEditor(self, column.editor, template, $compile, $scope); |
350 | 343 | } |
351 | 344 | if (valids = column.validations) { |
352 | 345 | for (var j = 0; j < valids.length; j++) { |
|
377 | 370 | $compile(tmpl)(edScope); |
378 | 371 | scope_editor = edScope.editor; |
379 | 372 | edScope.$destroy(); |
| 373 | + return $.extend(editor, scope_editor); |
380 | 374 | }; |
381 | 375 | }; |
382 | 376 | _p.templateCell = function(tmpl) { |
|
0 commit comments