コード例 #1
0
 }, function (element) {
     var data = element.value;
     if (ag_grid_community_1.Utils.missingOrEmpty(data))
         return;
     var parsedData = _this.dataToArray(data);
     var userFunc = _this.gridOptionsWrapper.getProcessDataFromClipboardFunc();
     if (userFunc) {
         parsedData = userFunc({ data: parsedData });
     }
     if (ag_grid_community_1.Utils.missingOrEmpty(parsedData))
         return;
     _this.eventService.dispatchEvent({
         type: ag_grid_community_1.Events.EVENT_PASTE_START,
         api: _this.gridOptionsWrapper.getApi(),
         columnApi: _this.gridOptionsWrapper.getColumnApi(),
         source: 'clipboard'
     });
     var singleCellInClipboard = parsedData.length == 1 && parsedData[0].length == 1;
     _this.rangeController.isMoreThanOneCell() && !singleCellInClipboard ?
         _this.pasteToRange(parsedData) : _this.pasteToSingleCell(parsedData);
     _this.eventService.dispatchEvent({
         type: ag_grid_community_1.Events.EVENT_PASTE_END,
         api: _this.gridOptionsWrapper.getApi(),
         columnApi: _this.gridOptionsWrapper.getColumnApi(),
         source: 'clipboard'
     });
 });
コード例 #2
0
ファイル: excelXmlFactory.js プロジェクト: Hyeong-jin/ag-grid
 ExcelXmlFactory.prototype.workbook = function (docProperties, eWorkbook, styles, worksheets) {
     var children = [
         docProperties,
         eWorkbook,
         this.stylesXmlElement(styles)
     ].concat(ag_grid_community_1.Utils.map(worksheets, function (it) { return worksheet_1.default.getTemplate(it); }));
     return ag_grid_community_1.Utils.assign({}, workbook_1.default.getTemplate(), { children: children });
 };
コード例 #3
0
 MenuItemComponent.prototype.init = function () {
     var _this = this;
     if (this.params.checked) {
         this.queryForHtmlElement('#eIcon').innerHTML = '<span class="ag-icon ag-icon-tick"></span>';
     }
     else if (this.params.icon) {
         if (ag_grid_community_1.Utils.isNodeOrElement(this.params.icon)) {
             this.queryForHtmlElement('#eIcon').appendChild(this.params.icon);
         }
         else if (typeof this.params.icon === 'string') {
             this.queryForHtmlElement('#eIcon').innerHTML = this.params.icon;
         }
         else {
             console.warn('ag-Grid: menu item icon must be DOM node or string');
         }
     }
     else {
         // if i didn't put space here, the alignment was messed up, probably
         // fixable with CSS but i was spending to much time trying to figure
         // it out.
         this.queryForHtmlElement('#eIcon').innerHTML = '&nbsp;';
     }
     if (this.params.tooltip) {
         this.getGui().setAttribute('title', this.params.tooltip);
     }
     if (this.params.shortcut) {
         this.queryForHtmlElement('#eShortcut').innerHTML = this.params.shortcut;
     }
     if (this.params.subMenu) {
         if (this.gridOptionsWrapper.isEnableRtl()) {
             // for RTL, we show arrow going left
             this.queryForHtmlElement('#ePopupPointer').classList.add('ag-icon-small-left');
         }
         else {
             // for normal, we show arrow going right
             this.queryForHtmlElement('#ePopupPointer').classList.add('ag-icon-small-right');
         }
     }
     else {
         this.queryForHtmlElement('#ePopupPointer').innerHTML = '&nbsp;';
     }
     this.queryForHtmlElement('#eName').innerHTML = this.params.name;
     if (this.params.disabled) {
         ag_grid_community_1.Utils.addCssClass(this.getGui(), 'ag-menu-option-disabled');
     }
     else {
         this.addGuiEventListener('click', this.onOptionSelected.bind(this));
     }
     if (this.params.cssClasses) {
         this.params.cssClasses.forEach(function (it) { return ag_grid_community_1.Utils.addCssClass(_this.getGui(), it); });
     }
 };
コード例 #4
0
ファイル: menuList.js プロジェクト: Hyeong-jin/ag-grid
 MenuList.prototype.showChildMenu = function (menuItemDef, menuItemComp, mouseEvent) {
     var _this = this;
     this.removeChildPopup();
     var childMenu = new MenuList();
     this.context.wireBean(childMenu);
     childMenu.addMenuItems(menuItemDef.subMenu);
     var ePopup = ag_grid_community_1.Utils.loadTemplate('<div class="ag-menu"></div>');
     ePopup.appendChild(childMenu.getGui());
     var hidePopupFunc = this.popupService.addAsModalPopup(ePopup, true, null, mouseEvent);
     this.popupService.positionPopupForMenu({
         eventSource: menuItemComp.getGui(),
         ePopup: ePopup
     });
     this.subMenuParentDef = menuItemDef;
     var selectedListener = function (event) {
         _this.dispatchEvent(event);
     };
     childMenu.addEventListener(menuItemComponent_1.MenuItemComponent.EVENT_ITEM_SELECTED, selectedListener);
     this.removeChildFuncs.push(function () {
         childMenu.clearActiveItem();
         childMenu.destroy();
         _this.subMenuParentDef = null;
         childMenu.removeEventListener(menuItemComponent_1.MenuItemComponent.EVENT_ITEM_SELECTED, selectedListener);
         hidePopupFunc();
     });
 };
コード例 #5
0
ファイル: contextMenu.js プロジェクト: Hyeong-jin/ag-grid
 ContextMenuFactory.prototype.showMenu = function (node, column, value, mouseEvent) {
     var _this = this;
     var menuItems = this.getMenuItems(node, column, value);
     if (ag_grid_community_1.Utils.missingOrEmpty(menuItems)) {
         return;
     }
     var menu = new ContextMenu(menuItems);
     this.context.wireBean(menu);
     var eMenuGui = menu.getGui();
     // need to show filter before positioning, as only after filter
     // is visible can we find out what the width of it is
     var hidePopup = this.popupService.addAsModalPopup(eMenuGui, true, function () { return menu.destroy(); }, mouseEvent);
     this.popupService.positionPopupUnderMouseEvent({
         column: column,
         rowNode: node,
         type: 'contextMenu',
         mouseEvent: mouseEvent,
         ePopup: eMenuGui
     });
     menu.afterGuiAttached({
         hidePopup: hidePopup
     });
     this.activeMenu = menu;
     menu.addEventListener(ag_grid_community_1.BeanStub.EVENT_DESTROYED, function () {
         if (_this.activeMenu === menu) {
             _this.activeMenu = null;
         }
     });
 };
コード例 #6
0
 ClipboardService.prototype.copyFocusedCellToClipboard = function (includeHeaders) {
     if (includeHeaders === void 0) { includeHeaders = false; }
     var focusedCell = this.focusedCellController.getFocusedCell();
     if (ag_grid_community_1.Utils.missing(focusedCell)) {
         return;
     }
     var currentRow = focusedCell.getGridRow();
     var rowNode = this.getRowNode(currentRow);
     var column = focusedCell.column;
     var value = this.valueService.getValue(column, rowNode);
     var processedValue = this.userProcessCell(rowNode, column, value, this.gridOptionsWrapper.getProcessCellForClipboardFunc(), ag_grid_community_1.Constants.EXPORT_TYPE_CLIPBOARD);
     if (ag_grid_community_1._.missing(processedValue)) {
         // copy the new line character to clipboard instead of an empty string, as the 'execCommand' will ignore it.
         // this behaviour is consistent with how Excel works!
         processedValue = '\n';
     }
     var data = '';
     if (includeHeaders) {
         data = this.columnController.getDisplayNameForColumn(column, 'clipboard', true) + '\r\n';
     }
     data += processedValue.toString();
     this.copyDataToClipboard(data);
     var cellId = focusedCell.createId();
     var cellsToFlash = {};
     cellsToFlash[cellId] = true;
     this.dispatchFlashCells(cellsToFlash);
 };
コード例 #7
0
 DropZoneColumnComp.prototype.onShowAggFuncSelection = function () {
     var _this = this;
     if (this.popupShowing) {
         return;
     }
     this.popupShowing = true;
     var virtualList = new virtualList_1.VirtualList();
     var rows = this.aggFuncService.getFuncNames(this.column);
     virtualList.setModel({
         getRow: function (index) { return rows[index]; },
         getRowCount: function () { return rows.length; }
     });
     this.context.wireBean(virtualList);
     var ePopup = ag_grid_community_1.Utils.loadTemplate('<div class="ag-select-agg-func-popup"></div>');
     ePopup.style.top = '0px';
     ePopup.style.left = '0px';
     ePopup.appendChild(virtualList.getGui());
     // ePopup.style.height = this.gridOptionsWrapper.getAggFuncPopupHeight() + 'px';
     ePopup.style.width = this.getGui().clientWidth + 'px';
     var popupHiddenFunc = function () {
         virtualList.destroy();
         _this.popupShowing = false;
     };
     var hidePopup = this.popupService.addAsModalPopup(ePopup, true, popupHiddenFunc);
     virtualList.setComponentCreator(this.createAggSelect.bind(this, hidePopup));
     this.popupService.positionPopupUnderComponent({
         type: 'aggFuncSelect',
         eventSource: this.getGui(),
         ePopup: ePopup,
         keepWithinBounds: true,
         column: this.column
     });
     virtualList.refresh();
 };
コード例 #8
0
ファイル: menuList.js プロジェクト: Hyeong-jin/ag-grid
 MenuList.prototype.removeActiveItem = function () {
     if (this.activeMenuItem) {
         ag_grid_community_1.Utils.removeCssClass(this.activeMenuItem.getGui(), 'ag-menu-option-active');
         this.activeMenuItem = null;
         this.activeMenuItemParams = null;
     }
 };
コード例 #9
0
 ClipboardService.prototype.pasteToSingleCell = function (parsedData) {
     var focusedCell = this.focusedCellController.getFocusedCell();
     if (!focusedCell) {
         return;
     }
     // remove last row if empty, excel puts empty last row in
     var lastLine = parsedData[parsedData.length - 1];
     if (lastLine.length === 1 && lastLine[0] === '') {
         ag_grid_community_1.Utils.removeFromArray(parsedData, lastLine);
     }
     var currentRow = new ag_grid_community_1.GridRow(focusedCell.rowIndex, focusedCell.floating);
     var cellsToFlash = {};
     var updatedRowNodes = [];
     var updatedColumnIds = [];
     var columnsToPasteInto = this.columnController.getDisplayedColumnsStartingAt(focusedCell.column);
     var onlyOneCellInRange = parsedData.length === 1 && parsedData[0].length === 1;
     if (onlyOneCellInRange) {
         this.singleCellRange(parsedData, updatedRowNodes, currentRow, cellsToFlash, updatedColumnIds);
     }
     else {
         this.multipleCellRange(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, updatedColumnIds, ag_grid_community_1.Constants.EXPORT_TYPE_CLIPBOARD);
     }
     // this is very heavy, should possibly just refresh the specific cells?
     this.rowRenderer.refreshCells({ rowNodes: updatedRowNodes, columns: updatedColumnIds });
     this.dispatchFlashCells(cellsToFlash);
     this.focusedCellController.setFocusedCell(focusedCell.rowIndex, focusedCell.column, focusedCell.floating, true);
     this.fireRowChanged(updatedRowNodes);
 };
コード例 #10
0
ファイル: virtualList.js プロジェクト: Hyeong-jin/ag-grid
 VirtualList.prototype.refresh = function () {
     if (ag_grid_community_1.Utils.missing(this.model)) {
         return;
     }
     this.eListContainer.style.height = (this.model.getRowCount() * this.rowHeight) + "px";
     this.clearVirtualRows();
     this.drawVirtualRows();
 };
コード例 #11
0
ファイル: agGridNg2.js プロジェクト: ceolter/ag-grid
 AgGridNg2.prototype.checkForDeprecatedEvents = function () {
     var _this = this;
     ag_grid_community_1.Utils.iterateObject(ag_grid_community_1.Events, function (key, eventName) {
         if (_this[eventName] && _this[eventName].observers.length > 0) {
             ag_grid_community_1.GridOptionsWrapper.checkEventDeprecation(eventName);
         }
     });
 };
コード例 #12
0
ファイル: excelXmlFactory.js プロジェクト: Hyeong-jin/ag-grid
 ExcelXmlFactory.prototype.stylesXmlElement = function (styles) {
     var _this = this;
     return {
         name: 'Styles',
         children: styles ? ag_grid_community_1.Utils.map(styles, function (it) {
             return _this.styleXmlElement(it);
         }) : []
     };
 };
コード例 #13
0
 DropZoneColumnComp.prototype.setupComponents = function () {
     this.setTextValue();
     this.setupRemove();
     if (this.ghost) {
         ag_grid_community_1.Utils.addCssClass(this.getGui(), 'ag-column-drop-cell-ghost');
     }
     if (this.valueColumn && !this.gridOptionsWrapper.isFunctionsReadOnly()) {
         this.addGuiEventListener('click', this.onShowAggFuncSelection.bind(this));
     }
 };
コード例 #14
0
 columns.forEach(function (column, index) {
     var value = _this.columnController.getDisplayNameForColumn(column, 'clipboard', true);
     var processedValue = _this.userProcessHeader(column, value, _this.gridOptionsWrapper.getProcessHeaderForClipboardFunc());
     if (index != 0) {
         data += deliminator;
     }
     if (ag_grid_community_1.Utils.exists(processedValue)) {
         data += processedValue;
     }
 });
コード例 #15
0
 clipboardRowData.forEach(function (value, index) {
     var column = columnsToPasteInto[index];
     if (ag_grid_community_1.Utils.missing(column)) {
         return;
     }
     if (!column.isCellEditable(rowNode)) {
         return;
     }
     _this.updateCellValue(rowNode, column, value, currentRow, cellsToFlash, updatedColumnIds, type);
 });
コード例 #16
0
 columns.forEach(function (column, index) {
     var value = _this.valueService.getValue(column, rowNode);
     var processedValue = _this.userProcessCell(rowNode, column, value, _this.gridOptionsWrapper.getProcessCellForClipboardFunc(), ag_grid_community_1.Constants.EXPORT_TYPE_CLIPBOARD);
     if (index != 0) {
         data += deliminator;
     }
     if (ag_grid_community_1.Utils.exists(processedValue)) {
         data += processedValue;
     }
     var gridCellDef = { rowIndex: currentRow.rowIndex, floating: currentRow.floating, column: column };
     var cellId = new ag_grid_community_1.GridCell(gridCellDef).createId();
     cellsToFlash[cellId] = true;
 });
コード例 #17
0
ファイル: virtualList.js プロジェクト: Hyeong-jin/ag-grid
 VirtualList.prototype.insertRow = function (value, rowIndex) {
     var eDiv = document.createElement('div');
     ag_grid_community_1.Utils.addCssClass(eDiv, 'ag-virtual-list-item');
     eDiv.style.top = (this.rowHeight * rowIndex) + "px";
     eDiv.style.lineHeight = this.rowHeight + "px";
     var rowComponent = this.componentCreator(value);
     eDiv.appendChild(rowComponent.getGui());
     this.eListContainer.appendChild(eDiv);
     this.rowsInBodyContainer[rowIndex] = {
         rowComponent: rowComponent,
         eDiv: eDiv
     };
 };
コード例 #18
0
 DropZoneColumnComp.prototype.setupRemove = function () {
     var _this = this;
     ag_grid_community_1.Utils.setVisible(this.btRemove, !this.gridOptionsWrapper.isFunctionsReadOnly());
     this.addDestroyableEventListener(this.btRemove, 'click', function (mouseEvent) {
         var agEvent = { type: DropZoneColumnComp.EVENT_COLUMN_REMOVE };
         _this.dispatchEvent(agEvent);
         mouseEvent.stopPropagation();
     });
     var touchListener = new ag_grid_community_1.TouchListener(this.btRemove);
     this.addDestroyableEventListener(touchListener, ag_grid_community_1.TouchListener.EVENT_TAP, function (event) {
         var agEvent = { type: DropZoneColumnComp.EVENT_COLUMN_REMOVE };
         _this.dispatchEvent(agEvent);
     });
     this.addDestroyFunc(touchListener.destroy.bind(touchListener));
 };
コード例 #19
0
ファイル: menuList.js プロジェクト: Hyeong-jin/ag-grid
 MenuList.prototype.mouseEnterItem = function (menuItemParams, menuItem) {
     if (menuItemParams.disabled) {
         return;
     }
     if (this.activeMenuItemParams !== menuItemParams) {
         this.removeChildPopup();
     }
     this.removeActiveItem();
     this.activeMenuItemParams = menuItemParams;
     this.activeMenuItem = menuItem;
     ag_grid_community_1.Utils.addCssClass(this.activeMenuItem.getGui(), 'ag-menu-option-active');
     if (menuItemParams.subMenu) {
         this.addHoverForChildPopup(menuItemParams, menuItem);
     }
 };
コード例 #20
0
 return new ag_grid_community_1.Promise(function (resolve) {
     _this.eParentElement = document.createElement('div');
     AgGrid.Utils.addCssClass(_this.eParentElement, 'ag-react-container');
     // so user can have access to the react container,
     // to add css class or style
     params.reactContainer = _this.eParentElement;
     // at some point soon unstable_renderSubtreeIntoContainer is going to be dropped (and in a minor release at that)
     // this uses the existing mechanism as long as possible, but switches over to using Portals when
     // unstable_renderSubtreeIntoContainer is no longer an option
     var reactLegacy = _this.useLegacyReact();
     if (reactLegacy) {
         _this.createReactComponentLegacy(params, resolve);
     }
     else {
         _this.createReactComponent(params, resolve);
     }
 });
コード例 #21
0
ファイル: menuList.js プロジェクト: Hyeong-jin/ag-grid
 MenuList.prototype.addMenuItems = function (menuItems) {
     var _this = this;
     if (ag_grid_community_1.Utils.missing(menuItems)) {
         return;
     }
     menuItems.forEach(function (menuItemOrString) {
         if (menuItemOrString === 'separator') {
             _this.addSeparator();
         }
         else if (typeof menuItemOrString === 'string') {
             console.warn("ag-Grid: unrecognised menu item " + menuItemOrString);
         }
         else {
             var menuItem = menuItemOrString;
             _this.addItem(menuItem);
         }
     });
 };
コード例 #22
0
 ClipboardService.prototype.copyDataToClipboard = function (data) {
     var userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc();
     if (ag_grid_community_1.Utils.exists(userProvidedFunc)) {
         var params = { data: data };
         userProvidedFunc(params);
     }
     else {
         this.executeOnTempElement(function (element) {
             element.value = data;
             element.select();
             element.focus();
             var result = document.execCommand('copy');
             if (!result) {
                 console.warn('ag-grid: Browser did not allow document.execCommand(\'copy\'). Ensure ' +
                     'api.copySelectedRowsToClipboard() is invoked via a user event, i.e. button click, otherwise ' +
                     'the browser will prevent it for security reasons.');
             }
         });
     }
 };
コード例 #23
0
 ClipboardService.prototype.iterateActiveRange = function (range, rowCallback, columnCallback, isLastRange) {
     // get starting and ending row, remember rowEnd could be before rowStart
     var startRow = range.start.getGridRow();
     var endRow = range.end.getGridRow();
     var startRowIsFirst = startRow.before(endRow);
     var currentRow = startRowIsFirst ? startRow : endRow;
     var lastRow = startRowIsFirst ? endRow : startRow;
     if (ag_grid_community_1.Utils.exists(columnCallback)) {
         columnCallback(range.columns);
     }
     var rangeIndex = 0;
     var isLastRow = false;
     // the currentRow could be missing if the user sets the active range manually, and sets a range
     // that is outside of the grid (eg. sets range rows 0 to 100, but grid has only 20 rows).
     while (!isLastRow && !ag_grid_community_1._.missing(currentRow)) {
         var rowNode = this.getRowNode(currentRow);
         isLastRow = currentRow.equals(lastRow);
         rowCallback(currentRow, rowNode, range.columns, rangeIndex++, isLastRow && isLastRange);
         currentRow = this.cellNavigationService.getRowBelow(currentRow);
     }
 };
コード例 #24
0
ファイル: contextMenu.js プロジェクト: Hyeong-jin/ag-grid
 ContextMenuFactory.prototype.getMenuItems = function (node, column, value) {
     var defaultMenuOptions;
     if (ag_grid_community_1.Utils.exists(node)) {
         defaultMenuOptions = [];
         if (column) {
             // only makes sense if column exists, could have originated from a row
             defaultMenuOptions = ['copy', 'copyWithHeaders', 'paste', 'separator'];
         }
         // if user clicks a cell
         var suppressExcel = this.gridOptionsWrapper.isSuppressExcelExport();
         var suppressCsv = this.gridOptionsWrapper.isSuppressCsvExport();
         var onIPad = ag_grid_community_1._.isUserAgentIPad();
         var anyExport = !onIPad && (!suppressExcel || !suppressCsv);
         if (anyExport) {
             defaultMenuOptions.push('export');
         }
     }
     else {
         // if user clicks outside of a cell (eg below the rows, or not rows present)
         // nothing to show, perhaps tool panels???
     }
     if (this.gridOptionsWrapper.getContextMenuItemsFunc()) {
         var userFunc = this.gridOptionsWrapper.getContextMenuItemsFunc();
         var params = {
             node: node,
             column: column,
             value: value,
             defaultItems: defaultMenuOptions,
             api: this.gridOptionsWrapper.getApi(),
             columnApi: this.gridOptionsWrapper.getColumnApi(),
             context: this.gridOptionsWrapper.getContext()
         };
         var menuItemsFromUser = userFunc(params);
         return menuItemsFromUser;
     }
     else {
         return defaultMenuOptions;
     }
 };
コード例 #25
0
ファイル: excelXmlFactory.js プロジェクト: Hyeong-jin/ag-grid
 ExcelXmlFactory.prototype.styleXmlElement = function (styleProperties) {
     var children = ag_grid_community_1.Utils.compose(this.addProperty('alignment', styleProperties), this.addProperty('borders', styleProperties), this.addProperty('font', styleProperties), this.addProperty('interior', styleProperties), this.addProperty('protection', styleProperties), this.addProperty('numberFormat', styleProperties))([]);
     return ag_grid_community_1.Utils.assign({}, style_1.default.getTemplate(styleProperties), { children: children });
 };
コード例 #26
0
ファイル: menuList.js プロジェクト: Hyeong-jin/ag-grid
 MenuList.prototype.addSeparator = function () {
     this.getGui().appendChild(ag_grid_community_1.Utils.loadTemplate(MenuList.SEPARATOR_TEMPLATE));
 };
コード例 #27
0
this.params.cssClasses.forEach(function (it) { return ag_grid_community_1.Utils.addCssClass(_this.getGui(), it); });