From: <die...@us...> - 2011-10-27 10:13:38
|
Revision: 3674 http://openutils.svn.sourceforge.net/openutils/?rev=3674&view=rev Author: diego_schivo Date: 2011-10-27 10:13:29 +0000 (Thu, 27 Oct 2011) Log Message: ----------- gridInsertRow Modified Paths: -------------- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl Modified: trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2011-10-22 06:20:23 UTC (rev 3673) +++ trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2011-10-27 10:13:29 UTC (rev 3674) @@ -53,11 +53,9 @@ row = cell0 + i; record = grid.store.getAt(row); if (!record && expand) { - if (!rt) { - rt = {}; - for (j = 0; j < J; j++) { - rt[''+j] = ''; - } + rt = {}; + for (j = 0; j < J; j++) { + rt[''+j] = ''; } record = new grid.store.recordType(rt); grid.store.add(record); @@ -128,6 +126,62 @@ } } +function gridInsertRow(grid) { + if (grid.selModel.selection) { + var j = grid.selModel.selection.cell[0], k, K = grid.colModel.getColumnCount(), rt = {}; + for (k = 0; k < K; k++) { + rt[''+k] = ''; + } + record = new grid.store.recordType(rt); + grid.store.insert(j, record); + } +} + +function gridDeleteRow(grid) { + if (grid.selModel.selection) { + var dat = grid.store.data, r1, r2, j1, j2, k, K = grid.colModel.getColumnCount(), field, e1, e2; + for (j1 = grid.selModel.selection.cell[0]; j1 < dat.length - 2; j1++) { + j2 = j1 + 1; + r1 = grid.store.getAt(j1); + r2 = grid.store.getAt(j2); + for (k = 0; k < K; k++) { + field = grid.colModel.getDataIndex(k); + e1 = { + grid: grid, + record: r1, + field: field, + originalValue: r1.data[field], + value: r2.data[field], + row: j1, + column: k, + cancel: false + }; + e2 = { + grid: grid, + record: r2, + field: field, + originalValue: r2.data[field], + value: '', + row: j2, + column: k, + cancel: false + }; + if(grid.fireEvent("validateedit", e1) !== false && !e1.cancel && grid.fireEvent("validateedit", e2) !== false && !e2.cancel){ + r1.set(field, e1.value); + delete e1.cancel; + grid.fireEvent("afteredit", e1); + + r2.set(field, e2.value); + delete e2.cancel; + grid.fireEvent("afteredit", e2); + + grid.selModel.select(j2, grid.selModel.selection.cell[1]); + } + } + } + } +} + // ]]> </script> @@ -247,21 +301,37 @@ mgnlOpenWindow('/.resources/controls/clipboard.html?name=${name}&expand=${addRowsEnabled?string}', 320, 200); } }, { - text: 'Move up', - tooltip: 'Move up', + text: '', + tooltip: 'Move row up', icon: '${request.contextPath}/.resources/controls/img/icon-move-up.png', iconCls: 'button-move-up', handler: function() { gridMoveRow(grid, -1); } }, { - text: 'Move down', - tooltip: 'Move down', + text: '', + tooltip: 'Move row down', icon: '${request.contextPath}/.resources/controls/img/icon-move-down.png', iconCls: 'button-move-down', handler: function() { gridMoveRow(grid, 1); } + }, { + text: '', + tooltip: 'Insert row', + icon: '${request.contextPath}/.resources/controls/img/icon-add.png', + iconCls: 'button-insert-row', + handler: function() { + gridInsertRow(grid); + } + }, { + text: '', + tooltip: 'Delete row', + icon: '${request.contextPath}/.resources/controls/img/icon-delete.png', + iconCls: 'button-delete-row', + handler: function() { + gridDeleteRow(grid); + } }], [#if (configuration.height??)] height: ${configuration.height}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |