/*!@license
* Infragistics.Web.ClientUI Grid Editing 21.2.12
*
* Copyright (c) 2011-2022 Infragistics Inc.
*
* http://www.infragistics.com/
*
* Depends on:
* jquery-1.9.1.js
* jquery.ui-1.9.0.js
* jquery.ui.widget.js
* infragistics.ui.grid.framework.js
* infragistics.ui.grid.shared.js
* infragistics.ui.editors.js
* infragistics.ui.validator.js
* infragistics.ui.combo.js
* infragistics.ui.rating.js
* infragistics.ui.shared.js
* infragistics.dataSource.js
* infragistics.util.js
*/
(function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.ui.grid.shared","./infragistics.ui.editors"],factory)}else{return factory(jQuery)}})(function($){"use strict";$.widget("ui.igGridUpdating",$.ui.igWidget,{options:{columnSettings:[{columnKey:null,editorType:null,editorProvider:null,editorOptions:null,required:null,readOnly:null,validation:null,defaultValue:null}],editMode:"row",enableDeleteRow:true,enableAddRow:true,validation:false,doneLabel:null,doneTooltip:null,cancelLabel:null,cancelTooltip:null,addRowLabel:null,addRowTooltip:null,deleteRowLabel:null,deleteRowTooltip:null,showDoneCancelButtons:true,enableDataDirtyException:true,startEditTriggers:"click,F2,enter",horizontalMoveOnEnter:false,excelNavigationMode:false,saveChangesSuccessHandler:null,saveChangesErrorHandler:null,swipeDistance:"100px",wrapAround:true,rowEditDialogOptions:{containment:"owner",width:"415px",height:"350px",animationDuration:200,showReadonlyEditors:true,showEditorsForHiddenColumns:false,namesColumnWidth:"150px",editorsColumnWidth:null,showDoneCancelButtons:true,dialogTemplate:null,dialogTemplateSelector:null,editorsTemplate:null,editorsTemplateSelector:null},dialogWidget:"igGridModalDialog",inherit:false,locale:{doneLabel:undefined,doneTooltip:undefined,cancelLabel:undefined,cancelTooltip:undefined,addRowLabel:undefined,addRowTooltip:undefined,deleteRowLabel:undefined,deleteRowTooltip:undefined}},events:{editRowStarting:"editRowStarting",editRowStarted:"editRowStarted",editRowEnding:"editRowEnding",editRowEnded:"editRowEnded",editCellStarting:"editCellStarting",editCellStarted:"editCellStarted",editCellEnding:"editCellEnding",editCellEnded:"editCellEnded",rowAdding:"rowAdding",rowAdded:"rowAdded",rowDeleting:"rowDeleting",rowDeleted:"rowDeleted",dataDirty:"dataDirty",generatePrimaryKeyValue:"generatePrimaryKeyValue",rowEditDialogBeforeOpen:"rowEditDialogBeforeOpen",rowEditDialogAfterOpen:"rowEditDialogAfterOpen",rowEditDialogBeforeClose:"rowEditDialogBeforeClose",rowEditDialogAfterClose:"rowEditDialogAfterClose",rowEditDialogContentsRendered:"rowEditDialogContentsRendered"},css:{buttonContainer:"ui-iggrid-buttoncontainer ui-widget-content ui-corner-all",button:"ui-iggrid-button ui-state-default ui-corner-all",doneButton:"ui-iggrid-donebutton ui-priority-primary ui-corner-all",cancelButton:"ui-iggrid-cancelbutton ui-corner-all",deleteButton:"ui-iggrid-deletebutton ui-state-default ui-corner-all",buttonHover:"ui-iggrid-buttonhover ui-state-hover",buttonDisabled:"ui-iggrid-buttondisabled ui-state-disabled",buttonActive:"ui-iggrid-buttonactive ui-state-active",doneIcon:"ui-iggrid-doneicon ui-icon ui-icon-check",cancelIcon:"ui-iggrid-cancelicon ui-icon ui-icon-cancel",buttonIconOnly:"ui-iggrid-button-icon-only",editingCell:"ui-iggrid-editingcell",addRow:"ui-iggrid-addrow ui-widget-header",addRowHover:"ui-iggrid-addrowhover ui-state-hover",addRowActive:"ui-iggrid-addrowactive ui-state-active",addRowIcon:"ui-iggrid-addrowicon ui-icon ui-icon-circle-plus",deleteIcon:"ui-iggrid-deleteicon ui-icon ui-icon-circle-close",editor:"ui-iggrid-editor",rowEditDialogHeaderCaptionTitle:"ui-dialog-title",rowEditDialogCloseButton:"ui-icon ui-icon-close",rowEditDialog:"ui-dialog ui-draggable ui-resizable ui-iggrid-dialog ui-widget ui-widget-content ui-corner-all",blockArea:"ui-widget-overlay ui-iggrid-blockarea",rowEditDialogButtonsContainer:"ui-dialog-buttonpane ui-widget-content ui-helper-clearfix",rowEditDialogTable:"ui-iggrid-filtertable ui-helper-reset"},_createWidget:function(){this.options.columnSettings=[];$.Widget.prototype._createWidget.apply(this,arguments)},setCellValue:function(rowId,colKey,value){var provider,providerWrapper;if(rowId===null||rowId===undefined||$.type(colKey)!=="string"){return}if(value===undefined){throw new Error(this._getLocaleValue("undefinedCellValue"))}if(!this._recOrPropFound(rowId,colKey)){throw new Error(this._getLocaleValue("recordOrPropertyNotFoundException"))}if(this.isEditing()&&this._editingForRowId===rowId){providerWrapper=this._providerForKey(colKey);if(this._originalValues.hasOwnProperty(colKey)&&providerWrapper){provider=providerWrapper.igEditorFilter("option","provider");provider.setValue(value);this._editorTextChanged();return}else{this.endEdit(false,false)}}this._updateCell(rowId,colKey,value)},updateRow:function(rowId,values){var key,provider,providerWrapper,shouldUpdate=false;if(rowId===null||rowId===undefined||$.type(values)!=="object"){return}if(!this._recOrPropFound(rowId)){throw new Error(this._getLocaleValue("recordOrPropertyNotFoundException"))}if(this.isEditing()&&this._editingForRowId===rowId){for(key in values){providerWrapper=this._providerForKey(key);if(values.hasOwnProperty(key)&&this._originalValues.hasOwnProperty(key)&&providerWrapper){provider=providerWrapper.igEditorFilter("option","provider");provider.setValue(values[key])}else{this.endEdit(false,false);shouldUpdate=true;break}}this._editorTextChanged()}else{shouldUpdate=true}if(shouldUpdate){this._updateRow(rowId,values,null,null)}},addRow:function(values){var settings=this.options.columnSettings,i=settings?settings.length:0,defVals={},key,val;while(i-- >0){key=settings[i].columnKey;val=settings[i].defaultValue;if(val!==undefined&&key!==undefined&&key!==null){defVals[key]=val}}this._addRow(null,$.extend(defVals,values),defVals,true)},deleteRow:function(rowId){if(rowId===null||rowId===undefined){return}if(!this._recOrPropFound(rowId)){throw new Error(this._getLocaleValue("recordOrPropertyNotFoundException"))}if(this.isEditing()&&this._editingForRowId===rowId){this.endEdit(false)}this._deleteRow(null,rowId,true)},startEdit:function(rowId,column,raiseEvents){var columnIndex,columnKey,mode=this.options.editMode,visibleColumns=this.grid._visibleColumns(),cell,row;if(this.isEditing()){throw new Error(this._getLocaleValue("editingInProgress"))}if($.type(column)==="string"){columnKey=column;columnIndex=this._getVisibleIndexForKey(columnKey)}else if($.type(column)==="number"&&column>=0&&column<visibleColumns.length){columnKey=visibleColumns[column].key;columnIndex=column}if(!columnKey||columnIndex===undefined||columnIndex===null){if(mode==="cell"){throw new Error(this._getLocaleValue("columnNotFound").replace("{key}",columnKey))}columnKey=visibleColumns[0].key;columnIndex=0}if(mode==="cell"&&visibleColumns[columnIndex].readOnly){return false}switch(mode){case"dialog":return this._startEditDialog(null,!raiseEvents,rowId,false,columnKey,cell);case"row":row=this.grid.rowById(rowId);if(!row||!row.length){throw new Error(this._getLocaleValue("rowOrColumnSpecifiedOutOfView"))}return this._startEditForRow(null,!raiseEvents,rowId,columnKey,row);case"cell":cell=this.grid.cellById(rowId,columnKey);if(!cell||!cell.length){throw new Error(this._getLocaleValue("rowOrColumnSpecifiedOutOfView"))}return this._startEditForCell(null,!raiseEvents,rowId,columnKey,cell,true,false)}},startAddRowEdit:function(raiseEvents){if(this.isEditing()){throw new Error(this._getLocaleValue("editingInProgress"))}if(!this.options.enableAddRow){return false}if(this.options.editMode==="dialog"){return this._startEditDialog(null,!raiseEvents,null,true,this.grid._visibleColumns()[0].key,null)}return this._startEditForRow(null,!raiseEvents,null,null,this.grid.headersTable().children("thead").children("[data-add-row]").children(":not([data-skip='true'])").first())},endEdit:function(update,raiseEvents){var dialog;if(!this.isEditing()){return}if(this.options.editMode==="dialog"){dialog=$("#"+this.grid.id()+"_updating_dialog_container");if(dialog&&dialog.data()[this.options.dialogWidget]){dialog[this.options.dialogWidget]("closeModalDialog",update,!!raiseEvents)}}else{return this._endEdit(null,!!update,!raiseEvents)}},findInvalid:function(){var key,all=this._editors,provider;for(key in all){if(all.hasOwnProperty(key)&&all[key]){provider=all[key].data("igEditorFilter").options.provider;provider.refreshValue();if(!all[key].data("igEditorFilter").options.provider.validate()){return key}}}return null},isEditing:function(){return!!this._originalValues},editorForKey:function(key){var provider;if(!this._editors||!this._editors[key]){return null}provider=this._editors[key];return provider.igEditorFilter("option","provider").editor.element},editorForCell:function(cell,create){var columnKey=this._getColumnKeyForCell(cell);if(!this._editors){this._editors={}}if(!this._editors[columnKey]&&create){this._editors[columnKey]=this._createEditor(cell,columnKey)}return this.editorForKey(columnKey)},destroy:function(){if(this.options.enableAddRow){this._removeAddRow()}if(this.options.enableDeleteRow){this._removeDeleteButton()}if(this.options.showDoneCancelButtons&&this.options.editMode==="row"){this._removeDoneCancelButtons()}this._destroyAllEditors();this._unbindAllEvents();delete this._stopEditingHandler;delete this._gridHandlers;delete this._handlers;delete this._buttonHandlers;delete this._addNewRowHandlers;delete this._validationHandlers;delete this._dialogHandlers;delete this._editorCallbacks;this._superApply(arguments);return this},changeRegional:function(){var regional=this.grid.options.regional,key;this._stopEditing();if(this._editors){for(key in this._editors){if(this._editors.hasOwnProperty(key)&&this._editors[key].data("igEditorFilter")&&!this.grid.columnByKey(key).regional){this._editors[key].data("igEditorFilter")._setRegional(regional)}}}},changeLocale:function(){var self=this,gridId=this.grid.id(),$elements=$(),key;$elements=$elements.add(this.grid.fixedHeadersTable().children("thead").children("tr[data-add-row='true']"));$elements=$elements.add(this.grid.headersTable().children("thead").children("tr[data-add-row='true']"));$elements=$elements.add($("#"+gridId+"_updating_deletehover"));$elements=$elements.add($("#"+gridId+"_updating_delete_touch"));$elements=$elements.add($("#"+gridId+"_updating_done"));$elements=$elements.add($("#"+gridId+"_updating_cancel"));$elements.each(function(){self._super($(this))});if($("#"+gridId+"_updating_dialog_container").length){this._changeLocaleUpdatingDialog()}if(this._editors){for(key in this._editors){if(this._editors.hasOwnProperty(key)&&this._editors[key].data("igEditorFilter")){this._editors[key].data("igEditorFilter")._setLanguage(this.grid.options.language)}}}this._superApply(arguments)},_registerWidget:$.noop,_unregisterWidget:$.noop,_changeLocaleUpdatingDialog:function(){var $updatingDialog=$("#"+this.grid.id()+"_updating_dialog_container");if($updatingDialog.data(this.options.dialogWidget)){$updatingDialog[this.options.dialogWidget]("option",{locale:{modalDialogCaptionText:this._getLocaleValue("rowEditDialogCaptionLabel"),buttonApplyText:this._getLocaleValue("doneLabel"),buttonApplyTitle:this._getLocaleValue("doneTooltip"),buttonCancelText:this._getLocaleValue("cancelLabel"),buttonCancelTitle:this._getLocaleValue("cancelTooltip")}})}},_setOption:function(key,value){var opts=this.options,vt=$.type(value);if(opts[key]===value&&vt!=="object"&&vt!=="array"){return this}if(key==="editMode"){this.endEdit(false,false);this._dialogInvalid=true;this._destroyAllEditors()}this._super(key,value);switch(key){case"rowEditDialogOptions":this._dialogInvalid=true;opts.rowEditDialogOptions=$.extend(opts.rowEditDialogOptions,value);break;case"enableDeleteRow":if(value===true){this._renderDeleteButton()}else{this._removeDeleteButton()}break;case"enableAddRow":if(value===true&&this.grid.options.showHeader){this._updateAddNewRow()}else{this._removeAddRow()}this._rebindEditTriggers();break;case"startEditTriggers":this._analyzeEditTriggers();this._rebindEditTriggers();break;case"columnSettings":this.endEdit(false,false);this._destroyAllEditors();this._processReadOnly();if(this.options.enableAddRow&&this.grid.options.showHeader){this._updateAddNewRow()}this.grid._renderData();this._gridDirty=true;this._dialogInvalid=true;break}if(key==="saveChangesSuccessHandler"){this._addDSSuccessHandler()}else if(key==="saveChangesErrorHandler"){this._addDSErrorHandler()}return this},_gridDataRendering:function(evt,ui){var ds,l,noCancel;if(ui&&ui.owner.id()!==this.grid.id()){return}ds=this.grid.dataSource;l=ds.data()?ds.data().length:0;if(!this.grid.options.showHeader){this._processReadOnly()}if(this.isEditing()){if(!this.endEdit(this.grid.options.autoCommit,true)){this.endEdit(false,true)}}this._pkVal=Math.max(this._pkVal||1,l+1);if(ds.pendingTransactions().length){if(this.options.enableDataDirtyException){noCancel=this._trigger(this.events.dataDirty,null,{owner:this});if(noCancel){throw new Error(this._getLocaleValue("dataDirtyException"))}}}if(l&&!this.grid.options.primaryKey){throw new Error(this._getLocaleValue("noPrimaryKeyDefined"))}this.hideDeleteButton()},_gridRendered:function(){this._rebindEditTriggers()},_rowsRendered:function(evt,ui){if(ui&&ui.owner&&ui.owner.id()!==this.grid.id()){return}this._paintModifiedCells()},_virtPreRender:function(evt,ui){if(ui&&ui.owner&&ui.owner.id()!==this.grid.id()){return}if(this.isEditing()&&!this._vscrolled){if(!this._endEdit(evt,true,false,true)){this._endEdit(evt,false,false,true)}}delete this._vscrolled},_virtPostRender:function(evt,ui){if(ui&&ui.owner&&ui.owner.id()!==this.grid.id()){return}this.hideDeleteButton();this._paintModifiedCells()},_headerRendered:function(evt,ui){if(ui.owner.id()!==this.grid.id()){return}this._updateAddNewRow()},_fixedColumnsChanged:function(){this._stopEditing();this._editorsContainerInvalid=true;if(this.options.enableAddRow){this._updateAddNewRow()}if(this.options.enableDeleteRow){this._removeDeleteButton();this._renderDeleteButton()}if(this.options.showDoneCancelButtons&&this.options.editMode==="row"){this._removeDoneCancelButtons()}},_groupedColumnsChanged:function(){if(this.options.enableAddRow){this._updateAddNewRow()}},_hidingFinishing:function(){if(this.isEditing()){if(!this.endEdit(true,true)){this.endEdit(false,true)}}},_columnsModified:function(evt,ui){if(ui.owner.id()!==this.grid.id()){return}this._editorsContainerInvalid=true;if(this.options.enableAddRow){this._updateAddNewRow()}this._paintModifiedCells()},_columnsMoved:function(){this._hideValidatorMessages()},_scroll:function(){if(this.isEditing()){if(this._editingForRowId!==undefined&&this._editingForRowId!==null){this._positionDoneCancelButtons(this.grid.rowById(this._editingForRowId))}else{this._positionDoneCancelButtons(this.grid.headersTable().find("tr[data-new-row]"))}this._hideValidatorMessages()}},_internalColumnResized:function(){this._stopEditing()},_mouseDown:function(evt){var target=$(evt.target).closest("td"),targetContainer=target.closest(".ui-iggrid"),originalTarget=evt.originalEvent.target instanceof $?evt.originalEvent.target[0]:evt.originalEvent.target,targetGrid=target.closest(this.grid._isMultiRowGrid()?".ui-iggrid-table-mrl":".ui-iggrid-table"),re=new RegExp("^"+this.grid.id()+"(_fixed)?$"),selection=this.grid.element.data("igGridSelection");if(evt.originalEvent&&evt.originalEvent.type==="touchstart"){this._cevt=originalTarget}else{if(this._cevt===originalTarget){this._cevt=null;return}}if(targetContainer.length&&targetContainer[0]===this.grid.container()[0]){if(this.isEditing()){if(!target.hasClass(this.css.editingCell)&&(this.options.editMode==="cell"||this._getRowId(target.closest("tr"))!==this._editingForRowId)){this._endEdit(evt,true,false,true)}}if(this.grid.headersTable().children("thead").has(target).length||this.grid.fixedHeadersTable().children("thead").has(target).length){return}if(targetGrid.length&&targetGrid.attr("id").match(re)){if(selection&&!target.hasClass("ui-iggrid-selectedcell")){this._wait=true}else{delete this._wait}}}},_clickTrigger:function(evt){var target=$(evt.target),targetCell=target.closest("td"),targetGrid=targetCell.closest(".ui-iggrid");if(targetGrid.length&&targetGrid[0]===this.grid.container()[0]&&!target.is("a")){if(this._wait){delete this._wait;if(evt.type!=="dblclick"){return}}this._startEditForElement(evt,targetCell)}},_keyDown:function(evt){var target=$(evt.target),targetGrid=target.closest(".ui-iggrid"),sel,row;if(!targetGrid.length||targetGrid[0]!==this.grid.container()[0]){return}if(target.is("td,tr")){if(evt.keyCode===$.ui.keyCode.ENTER&&this._editTriggers.enter||evt.keyCode===113&&this._editTriggers.f2){if(this.options.editMode==="cell"&&target.is("tr")){target=this._getEditableCellsForRow(target).first()}this._startEditForElement(evt,target)}else if(evt.keyCode===$.ui.keyCode.DELETE&&this.options.enableDeleteRow&&!this.isEditing()){sel=this.grid.element.data("igGridSelection");if(sel&&sel.options.mode==="row"&&sel.options.multipleSelection){this._deleteMultipleRows(evt)}else{row=target.closest("tr");if(this._isEditableRow(row)){this._deleteRow(evt,this._getRowId(row),false)}}}}},_touchStart:function(evt){this._firstTouchX=evt.originalEvent.touches&&evt.originalEvent.touches[0]?evt.originalEvent.touches[0].pageX:evt.originalEvent.clientX;this._firstTouchRow=evt.originalEvent.touches?$(evt.originalEvent.touches[0].target).closest("tr"):$(evt.originalEvent.target).closest("tr");this._storedScrollLeft=this.grid.scrollContainer().scrollLeft()||0;this._storedScrollWidth=this.grid.scrollContainer().width()||0;this.hideDeleteButton()},_touchEnd:function(evt){var changedTouchX=evt.originalEvent.changedTouches&&evt.originalEvent.changedTouches[0]?evt.originalEvent.changedTouches[0].pageX:evt.originalEvent.clientX,targetGrid=evt.target?$(evt.target).closest(".ui-iggrid-table"):null,re=new RegExp("^"+this.grid.id()+"(_fixed)?$");if(targetGrid&&targetGrid.length>0&&!targetGrid.attr("id").match(re)){return}this._storedScrollLeft-=this.grid.scrollContainer().scrollLeft()||0;this._storedScrollWidth-=this.grid.scrollContainer().width()||0;if(this.options.enableDeleteRow&&Math.abs(changedTouchX-this._firstTouchX)>parseInt(this.options.swipeDistance,10)&&this._firstTouchRow&&this._storedScrollLeft===0&&this._storedScrollWidth===0&&this._firstTouchRow.filter(":not([data-container],[data-grouprow],[data-summaryrow],.ui-iggrid-deletedrecord)").length){this.showDeleteButtonFor(this._firstTouchRow)}delete this._firstTouchX;delete this._firstTouchRow;delete this._storedScrollLeft;delete this._storedScrollWidth;delete this._firstTouchRow},_pointerDown:function(evt){var oe=evt.originalEvent;if(oe.pointerType!=="touch"){return}this._firstTouchX=oe.pageX;this._firstTouchRow=$(oe.target).closest("tr");this._storedScrollLeft=this.grid.scrollContainer().scrollLeft()||0;this._storedScrollWidth=this.grid.scrollContainer().width()||0;this.hideDeleteButton()},_pointerUp:function(evt){var oe=evt.originalEvent,changedTouchX;if(oe.pointerType!=="touch"){return}changedTouchX=oe.pageX;this._storedScrollLeft-=this.grid.scrollContainer().scrollLeft()||0;this._storedScrollWidth-=this.grid.scrollContainer().width()||0;if(this.options.enableDeleteRow&&Math.abs(changedTouchX-this._firstTouchX)>parseInt(this.options.swipeDistance,10)&&this._firstTouchRow&&this._storedScrollLeft===0&&this._storedScrollWidth===0&&this._firstTouchRow.filter(":not([data-container],[data-grouprow],[data-summaryrow],.ui-iggrid-deletedrecord)").length){this.showDeleteButtonFor(this._firstTouchRow)}delete this._firstTouchX;delete this._firstTouchRow;delete this._storedScrollLeft;delete this._storedScrollWidth;delete this._firstTouchRow},_addRowFocus:function(evt){$(evt.target).closest("tr").addClass(this.css.addRowActive)},_addRowBlur:function(evt){$(evt.target).closest("tr").removeClass(this.css.addRowActive)},_rowMouseEnter:function(evt){var row=$(evt.target).closest("tr");if(!this.isEditing()&&this._isEditableRow(row)){this.showDeleteButtonFor(row)}else{this.hideDeleteButton()}},_rowPointerEnter:function(evt){if(evt.originalEvent.pointerType==="mouse"){this._rowMouseEnter(evt)}},_containerMouseLeave:function(){this.hideDeleteButton()},_containerPointerLeave:function(evt){if(evt.originalEvent.pointerType!=="touch"){this.hideDeleteButton()}},_buttonMouseEnter:function(evt){var button=$(evt.target).closest(".ui-iggrid-button,.ui-iggrid-deletebutton");if(!button.hasClass("ui-state-disabled")){button.addClass(this.css.buttonHover)}},_buttonMouseLeave:function(evt){var button=$(evt.target).closest(".ui-iggrid-button,.ui-iggrid-deletebutton");button.removeClass(this.css.buttonHover)},_buttonFocus:function(evt){var button=$(evt.target).closest(".ui-iggrid-button,.ui-iggrid-deletebutton");if(!button.hasClass("ui-state-disabled")){button.addClass(this.css.buttonActive)}},_buttonBlur:function(evt){$(evt.target).removeClass(this.css.buttonActive)},_doneButtonClick:function(evt){var target=$(evt.target).closest(".ui-iggrid-button");if(!target.length||target.hasClass(this.css.buttonDisabled)){return}this._endEdit(evt,true)},_doneButtonKeyDown:function(evt){var cols=this._getColumnsOrderedByNavIndex();if(evt.keyCode===$.ui.keyCode.TAB&&evt.shiftKey){this._activateEditor(this._providerForKey(cols[cols.length-1].key))}},_doneButtonKeyUp:function(evt){var target=$(evt.target).closest(".ui-iggrid-button");if(!target.length||target.hasClass(this.css.buttonDisabled)||evt.keyCode!==$.ui.keyCode.ENTER){return}this._endEdit(evt,true)},_cancelButtonKeyDown:function(evt){var cols=this._getColumnsOrderedByNavIndex();if(evt.keyCode===$.ui.keyCode.TAB&&!evt.shiftKey){this._activateEditor(this._providerForKey(cols[0].key))}},_cancelButtonKeyUp:function(evt){if(evt.keyCode===$.ui.keyCode.ENTER){this._stopEditing()}},_deleteButtonClick:function(evt){var rowId=$(evt.target).closest(".ui-iggrid-deletebutton").data("button-for");if(this._deleteRow(evt,rowId,false)){this.hideDeleteButton()}},_touchDeleteButtonClick:function(evt){var rowId=this._editingForRowId,target=$(evt.target).closest(".ui-iggrid-button");if(this.isEditing()&&!target.hasClass(this.css.buttonDisabled)){this._endEdit(evt,false,false);this._deleteRow(evt,rowId,false)}},_touchDeleteButtonKeyUp:function(evt){var rowId,target=$(evt.target).closest(".ui-iggrid-button");if(evt.keyCode===$.ui.keyCode.ENTER){rowId=this._editingForRowId;if(this.isEditing()&&!target.hasClass(this.css.buttonDisabled)){this._endEdit(evt,false,false);this._deleteRow(evt,rowId,false)}}},_dialogCloseClick:function(evt){var dialog=$("#"+this.grid.id()+"_updating_dialog_container");if(dialog&&dialog.data()[this.options.dialogWidget]){dialog[this.options.dialogWidget]("closeModalDialog",false,evt)}},_dialogDone:function(evt,ui){ui.toClose=true},_dialogCancel:function(evt,ui){ui.toClose=true},_dialogClosing:function(evt,ui){var dialog=ui.modalDialog;if(ui.raiseEvents){this._trigger(this.events.rowEditDialogBeforeClose,evt,{owner:this,dialogElement:dialog})}return this._endEditDialog(evt,ui.accepted,ui.owner.getContent(),!ui.raiseEvents)},_dialogClosed:function(evt,ui){if(ui.raiseEvents){this._trigger(this.events.rowEditDialogAfterClose,evt,{owner:this,dialogElement:ui.modalDialog})}},_dialogOpening:function(evt,ui){var dialog=ui.modalDialog,opts=this.options.rowEditDialogOptions,rowId=this.grid._fixPKValue(dialog.attr("data-for-rowid")),isAdding=dialog.attr("data-isadding")==="true",content=dialog[this.options.dialogWidget]("getContent"),templateParent,she=opts.showEditorsForHiddenColumns,cols=$.extend([],this.grid.options.columns),values=isAdding?this._getDefaultValues():this._getLatestValues(rowId),cache=content.find("[data-render-tmpl]").children(),invalid=!!this._editorsContainerInvalid,at=dialog.data("at"),rArgs;if(cache.length){if(!invalid){cache.detach()}else{this._clearEditorsFromContainer(cache);cache.remove()}}this._renderDialogContent(content,values);this._initDialogEditors(content,cols,values);templateParent=content.find("[data-render-tmpl]");if(templateParent.length&&!templateParent.children().length){if(!invalid){cache.appendTo(templateParent)}else{this._renderDialogTemplate(templateParent,cols,!she);delete this._editorsContainerInvalid}}this._initDialogEditors(content,cols,values);if(isAdding&&!this._anyEditorInvalid()){this._enableDoneButton()}else{this._disableDoneButton()}this._originalValues=$.extend({},values,this._originalValues);rArgs={owner:this,rowAdding:isAdding,rowID:rowId};if(at!==null&&at!==undefined){rArgs=$.extend({parentID:at},rArgs)}this._trigger(this.events.rowEditDialogAfterOpen,evt,{owner:this,dialogElement:dialog});this._trigger(this.events.editRowStarted,evt,rArgs)},_dialogOpened:function(evt,ui){ui.shouldFocus=false;if(this._columnToFocus&&this._columnToFocus.data&&this._columnToFocus.data("igEditorFilter")){this._columnToFocus.igEditorFilter("setFocus")}},_editorErrorShowing:function(evt,ui){var colKey=this._getEditorKey(ui.owner.element);if(this._errorShownFor&&this._errorShownFor!==colKey){return false}},_editorErrorShown:function(evt,ui){var colKey=this._getEditorKey(ui.owner.element);this._errorShownFor=colKey;this._disableDoneButton()},_editorErrorHidden:function(){delete this._errorShownFor;this._enableDoneButton()},_editorTextChanged:function(){if(this._fromExitEditing){delete this._fromExitEditing;return}if(!this.findInvalid()){this._enableDoneButton()}else{this._disableDoneButton()}},_editorKeyDown:function(evt,ui,columnKey){var keyCode=evt.keyCode,rowId,editor=this._editors[columnKey],providerWrapper=editor.data("igEditorFilter"),provider,row=ui.owner.element.closest("tr"),isAdd=row.hasClass("ui-iggrid-addrow")||row.attr("data-new-row");if(!row.length){return}if(providerWrapper){provider=providerWrapper.options.provider}if(keyCode===$.ui.keyCode.ESCAPE){if(this._revertValueForEditor(provider,columnKey)){evt.stopPropagation();return}}if(this.options.editMode==="dialog"){return}rowId=isAdd?null:this._getRowId(row);this._navigateElement(evt,keyCode,row,rowId,columnKey,isAdd)},_stopEditing:function(){if(this.isEditing()){this._endEdit(null,false)}},_paintModifiedCells:function(){var transactions=this.grid.pendingTransactions(),tran,i;for(i=0;i<transactions.length;i++){tran=transactions[i];this._updateUIForTransaction(tran)}},_removeAddRow:function(){this.grid.fixedHeadersTable().children("thead").children("tr[data-add-row='true'],tr[data-new-row='true']").remove();this.grid.headersTable().children("thead").children("tr[data-add-row='true'],tr[data-new-row='true']").remove()},_updateAddNewRow:function(){if(this.grid.hasFixedColumns()){this._updateAddNewRowForTable(true)}this._updateAddNewRowForTable(false)},_updateAddNewRowForTable:function(fixed){var numOfCols,thead,i,j,addRow,newRow,vcols,ihc,layout,colgroup,headerTable;headerTable=fixed?this.grid.fixedHeadersTable():this.grid.headersTable();thead=headerTable.children("thead");this._renderAddNewRow(thead);vcols=$.extend([],this.grid._visibleColumns(fixed));ihc=this.grid._initialHiddenColumns;if(ihc&&ihc.length){for(i=0;i<ihc.length;i++){for(j=0;j<vcols.length;j++){if(ihc[i].key===vcols[j].key){$.ig.removeFromArray(vcols,j,j);break}}}}numOfCols=this.grid._isMultiRowGrid()?this.grid._recordHorizontalSize():vcols.length;addRow=thead.children("tr[data-add-row='true']");addRow.children("td:last").attr("colspan",numOfCols);layout=this.grid._isMultiRowGrid()?this.grid._multiRowLayoutRenderingHelper(fixed):this._generateDummyLayout(vcols);if(($.ig.util.isIE||$.ig.util.isEdge)&&!this.grid._allColumnWidthsInPercentage&&!this.grid._allColumnWidthsInPixels){colgroup=headerTable.find("colgroup").detach();colgroup.prependTo(headerTable)}for(i=0;i<layout.length;i++){newRow=thead.children("tr[data-new-row='true']").eq(i).empty();for(j=0;j<layout[i].length;j++){$("<td></td>").attr("aria-readonly",!!layout[i][j].col.readOnly).attr("aria-describedby",this.grid.id()+"_"+layout[i][j].col.key).attr("colspan",layout[i][j].cs||1).attr("rowspan",layout[i][j].rs||1).appendTo(newRow)}}newRow=thead.children("tr[data-new-row='true']");if(fixed&&this.grid.fixingDirection()==="left"||!fixed&&(this.grid.fixingDirection()!=="left"||!this.grid.hasFixedColumns())){addRow.find("th[data-skip='true'],td[data-skip='true']").remove();newRow.find("th[data-skip='true'],td[data-skip='true']").remove();this.grid._headerInit(addRow,null,true);this.grid._headerInit(newRow,null,true)}},_toggleAddRow:function(){var newRow=this.grid.headersTable().find("tr[data-new-row]"),addRow=this.grid.headersTable().find("tr[data-add-row]"),height;if(this.grid.hasFixedColumns()){newRow=newRow.add(this.grid.fixedHeadersTable().find("tr[data-new-row]"));addRow=addRow.add(this.grid.fixedHeadersTable().find("tr[data-add-row]"))}if(newRow.eq(0).is(":visible")){newRow.hide();addRow.show()}else{height=addRow.height();addRow.hide();newRow.show();newRow.css("height",height)}},_providerForKey:function(key){if(!this._editors){return null}return this._editors[key]||null},_startEditForElement:function(evt,target){var mode=this.options.editMode,td=target.is("td")?target:null,tr=target.is("tr")?target:target.parent(),isAdding=tr.hasClass("ui-iggrid-addrow"),rowId=isAdding?null:this._getRowId(tr),editEnded=true,col;if(mode==="dialog"){if(!td){td=tr.children("td:not([data-skip='true'],[data-parent='true'])").first()}if(!this._isDataCell(td)||!this._isEditableRow(tr)){return false}this._startEditDialog(evt,false,rowId,isAdding,null,td)}else if(mode==="row"||tr.hasClass("ui-iggrid-addrow")){if(!td){td=tr.children("td:not([data-skip='true'],[data-parent='true'])").first()}if(!this._isDataCell(td)||!this._isEditableRow(tr)){return false}if(this.isEditing()){if(this._editingForRowId===rowId){return false}editEnded=this._endEdit(evt,true,false)}return!editEnded?false:this._startEditForRow(evt,false,rowId,null,td)}else if(mode==="cell"){if(!this._isEditableCell(td)){return false}if(this.isEditing()){col=this._getColumnKeyForCell(td);if(rowId===this._editingForRowId&&col&&this._originalValues.hasOwnProperty(col)){return false}editEnded=this._endEdit(evt,true,false)}return!editEnded?false:this._startEditForCell(evt,false,rowId,col,td,true,isAdding)}return false},_startEditDialog:function(evt,suppress,rowId,adding,columnKey,element,at){var dialog=this._renderRowEditDialog(!!this._dialogInvalid),rArgs;rArgs={owner:this,rowAdding:adding,rowID:rowId};if(at!==null&&at!==undefined){dialog.data("at",at);rArgs=$.extend({parentID:at},rArgs)}if(!suppress&&!this._trigger(this.events.editRowStarting,evt,rArgs)){return false}dialog.attr({"data-for-rowid":rowId,"data-isadding":adding});if(!suppress){this._trigger(this.events.rowEditDialogBeforeOpen,evt,{owner:this,dialogElement:dialog})}this._disableDoneButton();if(element&&element.is("td")&&!columnKey){columnKey=this._getColumnKeyForCell(element)}this._columnToFocus=this._chooseColumnToFocus(adding,columnKey);dialog[this.options.dialogWidget]("openModalDialog");return true},_startEditForRow:function(evt,suppress,rowId,columnKey,element){var rowElement,args,editModeStarted=false,colElements,pair,columnToFocus=null,i,allValues,cellValue,isAdding,at;rowElement=this._resolveRowElement(element,rowId);isAdding=rowElement.hasClass("ui-iggrid-addrow");at=this.grid._normalizedKey(rowElement.data("parent-id"));args={owner:this,rowAdding:isAdding,rowID:rowId};if(at!==null&&at!==undefined){args=$.extend({parentID:at},args)}if(!suppress&&!this._trigger(this.events.editRowStarting,evt,args)){return}if(this._gridDirty){rowElement=this._resolveRowElement(isAdding?element:null,rowId);if(!rowElement||!rowElement.length){return}}if(isAdding){rowElement=this._combineRowElements(rowElement);if(!rowElement.attr("data-new-row")){rowElement=rowElement.siblings("[data-new-row]");this._toggleAddRow()}}if(element&&element.is("td")&&!columnKey){columnKey=this._getColumnKeyForCell(element)}if(this.grid._isMultiRowGrid()){columnToFocus=this._chooseColumnToFocusMrl(isAdding,columnKey)}else{columnToFocus=this._chooseColumnToFocus(isAdding,columnKey)}colElements=this._getEditableElementsForRow(rowElement);allValues=isAdding?this._getDefaultValues():this._getLatestValues(rowId);for(i=0;i<colElements.length;i++){pair=colElements[i];cellValue=allValues[pair.colKey]===undefined?null:allValues[pair.colKey];editModeStarted=this._startEditForCell(evt,suppress,rowId,pair.colKey,pair.element,pair.colKey===columnToFocus,isAdding,cellValue)||editModeStarted}if(editModeStarted){if(this.options.showDoneCancelButtons){this._showDoneCancelButtons();this._positionDoneCancelButtons(rowElement);
if(isAdding&&!this._anyEditorInvalid()){this._enableDoneButton()}else{this._disableDoneButton()}if(this._renderTouchUI){this._updateTouchButtons(isAdding)}}if(!suppress){this._trigger(this.events.editRowStarted,evt,args)}this._editingForRowId=isAdding?null:rowId;this._originalValues=$.extend({},allValues,this._originalValues);if(this._selectionMode()==="row"||isAdding){this._selectionToggle(rowElement)}}else{rowElement.children().removeClass(this.css.editingCell);return false}return true},_startEditForCell:function(evt,suppress,rowId,columnKey,element,focus,isAdding,value){var providerWrapper,provider,validator,args,editor,newValue,width,height;columnKey=columnKey||this._getColumnKeyForCell(element);rowId=rowId===null?this._getRowId(element.closest("tr")):rowId;if(element){element.addClass(this.css.editingCell);editor=this.editorForCell(element,true);providerWrapper=this._providerForKey(columnKey);if(providerWrapper){provider=providerWrapper.igEditorFilter("option","provider")}else{return false}height=element.outerHeight();width=element.outerWidth();width=this._isLastScrollableCell(element)?width-this.grid._scrollbarWidth():width}if(value===undefined){value=this._getLatestValues(rowId,columnKey);value=value===undefined?null:value}args={owner:this,rowID:rowId,columnIndex:this.grid.getVisibleIndexByKey(columnKey),columnKey:columnKey,editor:editor,value:value,rowAdding:isAdding};if(!suppress&&!this._trigger(this.events.editCellStarting,evt,args)){if(editor){provider.setValue(null)}element.removeClass(this.css.editingCell);return false}if(editor){providerWrapper.css("z-index",$.ig.getZIndex(this.grid.container())+1);providerWrapper.prependTo(element);provider.setSize(Math.max(8,width),Math.max(10,height));validator=provider.validator();newValue=args.value;provider.setValue(newValue,false,this.grid._calcOffsetForCol(this._origRec,this.grid.columnByKey(columnKey),true))}this._originalValues=this._originalValues||{};this._originalValues[columnKey]=editor&&newValue===value?provider.getValue():value;this._trigger(this.events.editCellStarted,evt,args);if(focus&&editor){this._activateEditor(providerWrapper)}this.hideDeleteButton();this._editingForRowId=rowId;if((this.options.editMode==="cell"||this._selectionMode()==="cell"&&focus)&&!isAdding){this._selectionToggle(element)}return true},_endEditDialog:function(evt,shouldUpdate,dialogContent,suppress){var newValues={},prevValues=this._originalValues,update,colElements,hasInvalid,add=dialogContent.parent().attr("data-isadding")==="true",noCancel,isChanged,rowId=this.grid._fixPKValue(dialogContent.parent().attr("data-for-rowid")),at=this.grid._fixPKValue(dialogContent.parent().data("at"));colElements=this._getEditedColumnElementsForDialog(dialogContent);if(shouldUpdate){hasInvalid=this._handleInvalid(colElements,evt);if(hasInvalid){return false}newValues=this._getNewValuesForRow(colElements);isChanged=this._compareValues(prevValues,newValues);if(add){newValues=$.extend({},prevValues,newValues)}}update={update:shouldUpdate&&(isChanged||add)};if(!suppress){noCancel=this._fireEndingEvents(evt,prevValues,newValues,colElements,rowId,add,update,at);if(!noCancel){return false}}delete this._originalValues;delete this._editingForRowId;if(update.update&&(this._compareValues(prevValues,newValues)||add)){if(add){this._addRow(evt,newValues,prevValues,suppress,at)}else{this._updateRow(prevValues[this.grid.options.primaryKey],newValues,null,null)}}if(!suppress){this._fireEndedEvents(evt,prevValues,newValues,colElements,rowId,add,update,at)}this._hideValidatorMessages();if(at!==null&&at!==undefined){dialogContent.parent().removeData("at")}delete this._fromExitEditing;return true},_endEdit:function(evt,shouldUpdate,suppress,dontToggle){var cell,row,rowId,colKey,colElements,hasInvalid,add,prevValues=this._originalValues,newValues={},isChanged,noCancel=true,update,val,at,self=this;cell=this.grid.container().find("."+this.css.editingCell).filter(function(){var clg=$(this).closest("table").attr("id");return clg===self.grid.element.attr("id")||clg===self.grid.headersTable().attr("id")||clg===self.grid.fixedBodyContainer().children("table").attr("id")||clg===self.grid.fixedHeadersTable().attr("id")}).first();row=cell.closest("tr");at=row.data("parent-id");rowId=this._getRowId(row);row=this._resolveRowElement(cell,rowId);add=!!row.data("new-row");colElements=this._getEditedColumnElementsForRow(row);if(shouldUpdate){hasInvalid=this._handleInvalid(colElements,evt);if(hasInvalid){return false}newValues=this._getNewValuesForRow(colElements);isChanged=this._compareValues(prevValues,newValues);if(add){newValues=$.extend({},prevValues,newValues)}}update={update:shouldUpdate&&(isChanged||add)};if(!suppress){noCancel=this._fireEndingEvents(evt,prevValues,newValues,colElements,rowId,add,update,this.grid._normalizedKey(at));if(!noCancel){return false}}this._closeEditingForRow(colElements);delete this._originalValues;delete this._editingForRowId;if(add){this._toggleAddRow()}if(update.update&&(this._compareValues(prevValues,newValues)||add)){if(add){this._addRow(evt,newValues,prevValues,suppress,at)}else if(this.options.editMode==="cell"){colKey=colElements[0].colKey;cell=colElements[0].element;val=newValues[colKey];this._updateCell(rowId,colKey,val,cell)}else{this._updateRow(rowId,newValues,prevValues,row)}}if(!suppress){this._fireEndedEvents(evt,prevValues,newValues,colElements,rowId,add,update)}this._hideDoneCancelButtons();this._hideValidatorMessages();this._selectionToggle(null,dontToggle);delete this._fromExitEditing;return true},_handleInvalid:function(colElements,evt){var i,key,editor,provider,providerWrapper;for(i=0;i<colElements.length;i++){key=colElements[i].colKey;editor=this._providerForKey(key);providerWrapper=editor.data("igEditorFilter");providerWrapper.options.provider.refreshValue();this._fromExitEditing=true;providerWrapper.exitEditMode();provider=providerWrapper.options.provider;if(editor&&editor.length&&editor.is(":visible")&&(providerWrapper.hasInvalidMessage()||!provider.requestValidate(evt)||!provider.isValid())){this._activateEditor(editor);this._disableDoneButton();return true}}return false},_fireEndingEvents:function(evt,prevValues,newValues,colElements,rowId,add,update,at){var i,colKey,editor,rArg,cArg,mode=this.options.editMode,noCancel;if(mode!=="cell"){rArg={owner:this,oldValues:prevValues,values:update.update?newValues:prevValues,rowID:rowId,update:update.update,rowAdding:add};if(at!==null&&at!==undefined){rArg=$.extend({parentID:at},rArg)}noCancel=this._trigger(this.events.editRowEnding,evt,rArg);if(update.update){update.update=rArg.update}if(!noCancel){return false}}if(mode!=="dialog"){for(i=0;i<colElements.length;i++){colKey=colElements[i].colKey;editor=this.editorForKey(colKey);cArg={owner:this,rowID:rowId,columnIndex:this.grid.getVisibleIndexByKey(colKey),columnKey:colKey,editor:editor,value:newValues.hasOwnProperty(colKey)?newValues[colKey]:prevValues[colKey],oldValue:prevValues[colKey],update:update.update&&newValues[colKey]!==prevValues[colKey],rowAdding:add};noCancel=this._trigger(this.events.editCellEnding,evt,cArg);if(!noCancel&&mode==="cell"){return false}newValues[colKey]=cArg.value;if(mode==="cell"&&!add){update.update=cArg.update}else{if(!cArg.update){newValues[colKey]=prevValues[colKey]}}}}return true},_fireEndedEvents:function(evt,prevValues,newValues,colElements,rowId,add,update,at){var i,colKey,editor,rArg,cArg,mode=this.options.editMode;if(mode!=="dialog"){for(i=0;i<colElements.length;i++){colKey=colElements[i].colKey;editor=this.editorForKey(colKey);cArg={owner:this,rowID:rowId,columnIndex:this.grid.getVisibleIndexByKey(colKey),columnKey:colKey,editor:editor,value:newValues.hasOwnProperty(colKey)?newValues[colKey]:prevValues[colKey],oldValue:prevValues[colKey],update:update.update&&newValues[colKey]!==prevValues[colKey],rowAdding:add};this._trigger(this.events.editCellEnded,evt,cArg)}}if(mode!=="cell"){rArg={owner:this,oldValues:prevValues,values:update.update?newValues:prevValues,rowID:rowId,update:update.update,rowAdding:add};if(at!==null&&at!==undefined){rArg=$.extend({parentID:at},rArg)}this._trigger(this.events.editRowEnded,evt,rArg)}},_getNewValuesForRow:function(colElements){var i,key,editor,provider,providerWrapper,newValues={};for(i=0;i<colElements.length;i++){key=colElements[i].colKey;editor=this._providerForKey(key);providerWrapper=editor.data("igEditorFilter");provider=providerWrapper.options.provider;newValues[key]=provider.getValue()}return newValues},_compareValues:function(prevValues,newValues){var key,noChange=true;for(key in newValues){if(newValues.hasOwnProperty(key)){if($.type(newValues[key])==="date"&&$.type(prevValues[key])==="date"){noChange=noChange&&newValues[key].getTime()===prevValues[key].getTime()}else{noChange=noChange&&newValues[key]===prevValues[key]}}}return!noChange},_closeEditingForRow:function(colElements){var i,colKey,editor,provider,providerWrapper;if($.ig.util.isIE&&document.activeElement){document.activeElement.blur()}for(i=0;i<colElements.length;i++){colKey=colElements[i].colKey;editor=this._providerForKey(colKey);providerWrapper=editor.data("igEditorFilter");provider=providerWrapper.options.provider;providerWrapper.remove();colElements[i].element.closest("td").removeClass(this.css.editingCell)}},_createEditor:function(cell,columnKey,element){var vh=this._validationHandlers,colSetting=this._getColSettingsForCol(columnKey),column=this.grid.columnByKey(columnKey),provider=colSetting?colSetting.editorProvider:null,editorOptions=colSetting?$.extend(true,{},colSetting.editorOptions)||{}:{},editorType=colSetting?colSetting.editorType:null,validatorOptions,required,editorMargins,wrapper,elem,format=column.format,regional=column.regional||this.grid.options.regional,lang=this.grid.options.language;editorMargins=!element?this._getEditorMargins(cell):null;if(colSetting){validatorOptions=editorOptions.validatorOptions;required=colSetting.required;if(!validatorOptions&&(colSetting.validation||required)){validatorOptions={}}if(required){validatorOptions.required=true;editorOptions.required=true}}if(!validatorOptions&&this.options.validation){validatorOptions={};if(!editorOptions){editorOptions={}}}if(validatorOptions){if(!this.grid.element.igValidator){throw new Error(this._getLocaleValue("igValidatorException"))}if(colSetting&&!colSetting.editorOptions){colSetting.editorOptions=editorOptions}editorOptions.validatorOptions=validatorOptions;validatorOptions.notificationOptions=validatorOptions.notificationOptions||{};if(!element){validatorOptions.notificationOptions.mode="popover";validatorOptions.notificationOptions.containment=this.grid.container();validatorOptions.notificationOptions.appendTo=this.grid.container()}if(validatorOptions.notificationOptions.mode==="popover"&&element){validatorOptions.notificationOptions.containment=$(element.context);validatorOptions.notificationOptions.appendTo=$(element.context)}}if(!provider){provider=$.ig.GetEditorProvider(this.grid,column,editorType)}editorOptions.language=lang;editorOptions.regional=regional;elem=provider.createEditor(this._editorCallbacks,columnKey,editorOptions?editorOptions||null:null,this._getNextTabIndex(),format,element,this.grid._calcOffsetForCol(null,column,true));provider.attachErrorEvents(vh.errorShowing,vh.errorShown,vh.errorHidden);if(!element){elem.addClass(this.css.editor).css({marginLeft:editorMargins.x+"px",marginTop:editorMargins.y+"px"});elem.css("position","absolute")}wrapper=elem.igEditorFilter({provider:provider});return wrapper},_getEditorKey:function(element){var id=element.attr("id"),colKey,idx;if(id&&id.length){idx=id.indexOf("_editorfor_");colKey=idx>0?id.substring(idx+10):null}if(!colKey){colKey=this._getColumnKeyForCell(element.closest("td"))}return colKey},_getEditorMargins:function(cell){if(!cell||!cell.length){return{x:0,y:0}}if(!this._editorMargins){var btw=parseInt(cell.css("borderTopWidth"),10);var paddingTop=parseInt(cell.css("paddingTop"),10);var blw=parseInt(cell.css("borderLeftWidth"),10);var paddingLeft=parseInt(cell.css("paddingLeft"),10);this._editorMargins={x:-1*(paddingLeft+blw),y:-1*(paddingTop+btw)}}return this._editorMargins},_getColSettingsForCol:function(colKey){var i,settings=this.options.columnSettings;if(!settings){return null}for(i=0;i<settings.length;i++){if(settings[i].columnKey===colKey){return settings[i]}}},_destroyAllEditors:function(){var key;for(key in this._editors){if(this._editors.hasOwnProperty(key)){if(this._editors[key].data("igEditorFilter")){this._editors[key].igEditorFilter("destroy");this._editors[key].remove()}}}delete this._editors},_navigateElement:function(evt,keyCode,row,rowId,columnKey,isAdd){if(keyCode===$.ui.keyCode.TAB||this.options.horizontalMoveOnEnter&&keyCode===$.ui.keyCode.ENTER){if(evt.shiftKey){return this._navigateLeft(evt,row,rowId,columnKey,isAdd)}return this._navigateRight(evt,row,rowId,columnKey,isAdd)}if(keyCode===$.ui.keyCode.ENTER){if(isAdd){return this._endEdit(evt,true,false)}if(evt.shiftKey){return this._navigateUp(evt,rowId,columnKey)}return this._navigateDown(evt,rowId,columnKey)}if(keyCode===$.ui.keyCode.ESCAPE){return this._stopEditing()}if(this.options.excelNavigationMode){switch(keyCode){case $.ui.keyCode.LEFT:return this._navigateLeft(evt,row,rowId,columnKey,isAdd);case $.ui.keyCode.RIGHT:return this._navigateRight(evt,row,rowId,columnKey,isAdd);case $.ui.keyCode.DOWN:if(!isAdd){return this._navigateDown(evt,rowId,columnKey)}break;case $.ui.keyCode.UP:if(!isAdd){return this._navigateUp(evt,rowId,columnKey)}break}}},_navigateLeft:function(evt,row,rowId,columnKey,isAdd){if(!isAdd&&this.options.editMode==="cell"){if(this.grid._isMultiRowGrid()){return this._navigateLeftForMultiCell(evt,rowId,columnKey)}return this._navigateLeftForCell(evt,rowId,columnKey)}if(this.grid._isMultiRowGrid()){return this._navigateLeftForMultiRow(evt,row,rowId,columnKey,isAdd)}return this._navigateLeftForRow(evt,row,rowId,columnKey,isAdd)},_navigateLeftForRow:function(evt,row,rowId,columnKey,isAdd){var i,prevRow,prevCell,pairs=this._getEditedColumnElementsForRow(row),db,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;for(i=0;i<pairs.length;i++){if(pairs[i].colKey===columnKey){break}}if(i===0){if(this.options.showDoneCancelButtons){db=$("#"+this.grid.id()+"_updating_done");if(db.hasClass(this.css.buttonDisabled)){db.siblings().first().focus()}else{db.focus()}return}if(!this._endEdit(evt,true,false)||isAdd){return}row=this.grid.rowById(rowId);prevRow=this._nextEditableDataRow(row,"prev");if(!prevRow.length&&wrap){prevRow=this._lastEditableDataRow()}if(!prevRow.length){return}prevCell=this._getEditableCellsForRow(prevRow).last();this._startEditForRow(evt,false,this._getRowId(prevRow),this._getColumnKeyForCell(prevCell),prevCell);evt.preventDefault()}else if(this.grid.columnByKey(pairs[i].colKey).fixed!==this.grid.columnByKey(columnKey).fixed){this._activateEditor(this._providerForKey(pairs[i-1].colKey))}else{this._scrollTo(pairs[i-1].element)}},_navigateLeftForCell:function(evt,rowId,columnKey){var i,cols=this.grid._visibleColumns(),nextCell,curRow,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;curRow=this.grid.rowById(rowId);if(!this._endEdit(evt,true,false,true)){return}if(!$.contains(document.documentElement,curRow[0])){curRow=this.grid.rowById(rowId)}for(i=0;i<cols.length;i++){if(cols[i].key===columnKey){break}}while(curRow.length){rowId=this._getRowId(curRow);while(--i>=0){if(!cols[i].readOnly){nextCell=this.grid.cellById(rowId,cols[i].key);if(nextCell.css("display")==="none"){continue}this._startEditForCell(evt,false,rowId,cols[i].key,nextCell,true,false);evt.preventDefault();return}}curRow=this._nextEditableDataRow(curRow,"prev");if(!curRow.length&&wrap){curRow=this._lastEditableDataRow()}i=cols.length}},_navigateLeftForMultiRow:function(evt,row,rowId,columnKey,isAdd){var ni=this.grid.columnByKey(columnKey).navigationIndex,i,db,prevRow,prevCell,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization,cols=this._getColumnsOrderedByNavIndex();evt.preventDefault();for(i=0;i<cols.length;i++){if(cols[i].navigationIndex===ni){break}}if(i===0){if(this.options.showDoneCancelButtons){db=$("#"+this.grid.id()+"_updating_cancel");db.focus();return}if(!this._endEdit(evt,true,false)||isAdd){return}if(row.length){row=this._resolveRowElement(null,this._getRowId(row))}prevRow=this._nextEditableDataRow(row,"prev");if(!prevRow.length&&wrap){prevRow=this._lastEditableDataRow()}if(!prevRow.length){return}prevCell=prevRow.children("td[data-navindex='"+cols[cols.length-1].navigationIndex+"']");this._startEditForRow(evt,false,this._getRowId(prevRow),this._getColumnKeyForCell(prevCell),prevCell)}else{this._activateEditor(this._providerForKey(cols[i-1].key))}},_navigateLeftForMultiCell:function(evt,rowId,columnKey){var i,cols=this._getColumnsOrderedByNavIndex(),nextCell,curRow,ni,ncol,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;curRow=this.grid.rowById(rowId);if(!this._endEdit(evt,true,false,true)){return}if(!$.contains(document.documentElement,curRow[0])){curRow=this.grid.rowById(rowId)}for(i=0;i<cols.length;i++){if(cols[i].key===columnKey){break}}ni=cols[i].navigationIndex;while(curRow.length){rowId=this._getRowId(curRow);while(--ni>=0){ncol=this._getColumnByNavigationIndex(ni);if(!ncol.readOnly){nextCell=this.grid.cellById(rowId,ncol.key);this._startEditForCell(evt,false,rowId,ncol.key,nextCell,true,false);evt.preventDefault();return}}curRow=this._nextEditableDataRow(curRow,"prev");if(!curRow.length&&wrap){curRow=this._lastEditableDataRow()}ni=this.grid.options.columns.length}},_navigateRight:function(evt,row,rowId,columnKey,isAdd){if(!isAdd&&this.options.editMode==="cell"){if(this.grid._isMultiRowGrid()){return this._navigateRightForMultiCell(evt,rowId,columnKey)}return this._navigateRightForCell(evt,rowId,columnKey)}if(this.grid._isMultiRowGrid()){return this._navigateRightForMultiRow(evt,row,rowId,columnKey,isAdd)}return this._navigateRightForRow(evt,row,rowId,columnKey,isAdd)},_navigateRightForCell:function(evt,rowId,columnKey){var i,cols=this.grid._visibleColumns(),nextCell,curRow,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;curRow=this.grid.rowById(rowId);if(!this._endEdit(evt,true,false,true)){return}if(!$.contains(document.documentElement,curRow[0])){curRow=this.grid.rowById(rowId)}for(i=0;i<cols.length;i++){if(cols[i].key===columnKey){break}}while(curRow.length){rowId=this._getRowId(curRow);while(++i<cols.length){if(!cols[i].readOnly){nextCell=this.grid.cellById(rowId,cols[i].key);if(nextCell.css("display")==="none"){continue}this._startEditForCell(evt,false,rowId,cols[i].key,nextCell,true,false);evt.preventDefault();return}}curRow=this._nextEditableDataRow(curRow,"next");if(!curRow.length&&wrap){curRow=this._firstEditableDataRow()}i=-1}},_navigateRightForRow:function(evt,row,rowId,columnKey,isAdd){var i,nextRow,nextCell,pairs=this._getEditedColumnElementsForRow(row),wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;for(i=0;i<pairs.length;i++){if(pairs[i].colKey===columnKey){break}}if(i===pairs.length-1){if(this.options.showDoneCancelButtons){return}if(!this._endEdit(evt,true,false)||isAdd){return}row=this.grid.rowById(rowId);nextRow=this._nextEditableDataRow(row,"next");if(!nextRow.length&&wrap){nextRow=this._firstEditableDataRow()}if(!nextRow.length){return}nextCell=this._getEditableCellsForRow(nextRow).first();this._startEditForRow(evt,false,this._getRowId(nextRow),this._getColumnKeyForCell(nextCell),nextCell);evt.preventDefault()}else if(this.grid.columnByKey(pairs[i].colKey).fixed!==this.grid.columnByKey(columnKey).fixed){this._activateEditor(this._providerForKey(pairs[i+1].colKey))}else{this._scrollTo(pairs[i+1].element)}},_navigateRightForMultiRow:function(evt,row,rowId,columnKey,isAdd){var ni=this.grid.columnByKey(columnKey).navigationIndex,i,db,nextRow,nextCell,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization,cols=this._getColumnsOrderedByNavIndex();evt.preventDefault();for(i=0;i<cols.length;i++){if(cols[i].navigationIndex===ni){break}}evt.preventDefault();if(i===cols.length-1){if(this.options.showDoneCancelButtons){db=$("#"+this.grid.id()+"_updating_done");if(db.hasClass(this.css.buttonDisabled)){db.siblings().first().focus()}else{db.focus()}return}if(!this._endEdit(evt,true,false)||isAdd){return}if(row.length){row=this._resolveRowElement(null,this._getRowId(row))}nextRow=this._nextEditableDataRow(row,"next");if(!nextRow.length&&wrap){nextRow=this._firstEditableDataRow()}if(!nextRow.length){return}nextCell=nextRow.children("td[data-navindex='"+cols[0].navigationIndex+"']");this._startEditForRow(evt,false,this._getRowId(nextRow),this._getColumnKeyForCell(nextCell),nextCell)}else{this._activateEditor(this._providerForKey(cols[i+1].key))}},_navigateRightForMultiCell:function(evt,rowId,columnKey){var i,cols=this._getColumnsOrderedByNavIndex(),nextCell,curRow,ni,ncol,wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;curRow=this.grid.rowById(rowId);if(!this._endEdit(evt,true,false,true)){return}if(!$.contains(document.documentElement,curRow[0])){curRow=this.grid.rowById(rowId)}for(i=0;i<cols.length;i++){if(cols[i].key===columnKey){break}}ni=cols[i].navigationIndex;while(curRow.length){rowId=this._getRowId(curRow);while(++ni<this.grid.options.columns.length){ncol=this._getColumnByNavigationIndex(ni);if(!ncol.readOnly){nextCell=this.grid.cellById(rowId,ncol.key);this._startEditForCell(evt,false,rowId,ncol.key,nextCell,true,false);evt.preventDefault();return}}curRow=this._nextEditableDataRow(curRow,"next");if(!curRow.length&&wrap){curRow=this._firstEditableDataRow()}ni=-1}},_navigateUp:function(evt,rowId,columnKey){var nextCell,curRow,wrap;wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;evt.preventDefault();evt.stopPropagation();if(!this._endEdit(evt,true,false,true)){return}curRow=this._nextEditableDataRow(this.grid.rowById(rowId),"prev");if(!curRow.length&&wrap){curRow=this._lastEditableDataRow()}if(curRow.length){rowId=this._getRowId(curRow);nextCell=this.grid.cellById(rowId,columnKey);if(this.options.editMode==="row"&&nextCell.css("display")!=="none"){this._startEditForRow(evt,false,rowId,columnKey,nextCell)}else{this._startEditForCell(evt,false,rowId,columnKey,nextCell,true,false)}evt.originalEvent.stopPropagation();evt.originalEvent.preventDefault()}},_navigateDown:function(evt,rowId,columnKey){var nextCell,curRow,wrap;wrap=this.options.wrapAround&&!this.grid.options.virtualization&&!this.grid.options.rowVirtualization;evt.preventDefault();evt.stopPropagation();if(!this._endEdit(evt,true,false,true)){return}curRow=this._nextEditableDataRow(this.grid.rowById(rowId),"next");if(!curRow.length&&wrap){curRow=this._firstEditableDataRow()}if(curRow.length){rowId=this._getRowId(curRow);nextCell=this.grid.cellById(rowId,columnKey);if(this.options.editMode==="row"&&nextCell.css("display")!=="none"){this._startEditForRow(evt,false,rowId,columnKey,nextCell)}else{this._startEditForCell(evt,false,rowId,columnKey,nextCell,true,false)}evt.originalEvent.stopPropagation();evt.originalEvent.preventDefault()}},_nextEditableDataRow:function(row,command){var go=this.grid.options,vVirt=go.virtualization||go.rowVirtualization,cIdx,query=":not([data-container],[data-grouprow],[data-summaryrow],"+".ui-iggrid-deletedrecord,[data-id='"+row.attr("data-id")+"']):visible:first";if(vVirt){if(go.virtualizationMode==="fixed"){cIdx=row.index();if(cIdx>=this.grid._virtualRowCount-1&&command==="next"){this._scrollVmanual(true);return this._lastEditableDataRow()}if(cIdx<=0&&command==="prev"){this._scrollVmanual(false);return this._firstEditableDataRow()}}}row=row[command+"All"](query);if(row.length){row=this._resolveRowElement(null,this._getRowId(row))}if(vVirt&&go.virtualizationMode==="continuous"){this._setScroll(command==="next"?$.ui.keyCode.DOWN:$.ui.keyCode.UP,row)}return row},_firstEditableDataRow:function(){return this.element.children("tbody").children("tr:not([data-grouprow],[data-summaryrow],.ui-iggrid-deletedrecord):visible:first")},_lastEditableDataRow:function(){return this.element.children("tbody").children("tr:not([data-container],.ui-iggrid-deletedrecord):visible:last")},_updateUnboundValuesForRow:function(row){if(!this.grid._hasUnboundColumns){return}var i,uc=this.grid._unboundColumns,col,f,dataRec,key=row[this.grid.options.primaryKey],ind;if(!uc||!uc.length){return}for(i=0;i<uc.length;i++){col=uc[i];if(col&&col.editModeUnboundValues!=="manual"&&col.formula){if(col.formula){f=this.grid._getUnboundColumnFormula(col);if(f){row[col.key]=f.apply(col,[row,this.grid.element]);dataRec=this.grid.findRecordByKey(key);if(!dataRec){return}ind=this.grid.dataSource.data().indexOf(dataRec);dataRec[col.key]=f.apply(col,[dataRec,this.grid.element]);this.grid._addUnboundColumnValue(col.key,row[col.key],ind)}}}}},_isEditableRow:function(row){var targetGrid=row.closest(this.grid._isMultiRowGrid()?".ui-iggrid-table-mrl,.ui-iggrid-headertable-mrl":".ui-iggrid-table,.ui-iggrid-headertable"),re=new RegExp("^"+this.grid.id()+"(_headers)?(_fixed)?$");return row&&row.is("tr")&&!row.hasClass(this.grid.css.deletedRecord)&&!row.attr("data-grouprow")&&!row.attr("data-summaryrow")&&(row.attr("data-id")!==undefined||row.attr("data-add-row")!==undefined)&&targetGrid.length&&targetGrid.attr("id").match(re)},_isEditableCell:function(cell){return this._isDataCell(cell)&&cell.attr("aria-readonly")!=="true"&&this._isEditableRow(cell.parent())},_isDataCell:function(cell){return cell&&cell.is("td")&&!cell.attr("data-skip")&&!cell.attr("data-parent")},_isLastScrollableCell:function(cell){return cell&&cell.is(":last-child")&&(parseInt(cell.css("padding-right"),10)>12||this.grid._hscrollbar().is(":visible")&&this.grid._hasVerticalScrollbar)&&this.grid.scrollContainer()&&this.grid.scrollContainer().has(cell).length},_selectionToggle:function(element,dontToggle){var sel=this.grid.element.data("igGridSelection");if(!sel){return}sel._suspend=!sel._suspend;if(element||dontToggle){this._actElement=element}else{this._actElement.focus()}},_selectionMode:function(){var sel=this.grid.element.data("igGridSelection");if(!sel){return null}return this.grid.element.data("igGridSelection").options.mode},_showDoneCancelButtons:function(){var container=this._findElementInScrollContainer(".ui-iggrid-buttoncontainer:first");if(!container.length){container=this._renderDoneCancelButtons()}container.show()},_hideDoneCancelButtons:function(){var container=this._findElementInScrollContainer(".ui-iggrid-buttoncontainer:first");if(container.length){container.hide()}},_positionDoneCancelButtons:function(row){var container=this._findElementInScrollContainer(".ui-iggrid-buttoncontainer:first"),sbw=this.grid._hasVerticalScrollbar===true?this.grid._scrollbarWidth():0,left,top,sc,contHeight,scHeight,rowPos,go=this.grid.options,v,hasHeight=go.height!==null&&go.height!==undefined,scrContainer;row=this._combineRowElements(row);sc=container.parent();left=sc.outerWidth()-container.outerWidth()-sbw+sc.scrollLeft();if(!sc.has(row).length&&sc[0]!==this.grid.container()[0]){top=sc.scrollTop()}else{contHeight=container.outerHeight();scHeight=sc.outerHeight();rowPos=row.last().igPosition();top=rowPos.top+row.outerHeight();if(top+contHeight>scHeight){top=row.first().igPosition().top-contHeight}if(!hasHeight){v=go.virtualization||go.rowVirtualization||go.columnVirtualization;scrContainer=v?this.grid._vdisplaycontainer():this.grid.scrollContainer();if(scrContainer.length){top+=scrContainer.igPosition().top}}top+=sc.scrollTop()}container.css({top:top,left:left})},_disableDoneButton:function(){if(this.options.editMode==="dialog"){$("#"+this.grid.id()+"_updating_dialog_container")[this.options.dialogWidget]("option","buttonApplyDisabled",true)}else{$("#"+this.grid.id()+"_updating_done").addClass(this.css.buttonDisabled).removeClass(this.css.buttonActive).attr("tabIndex",-1)}},_enableDoneButton:function(){if(this.options.editMode==="dialog"){$("#"+this.grid.id()+"_updating_dialog_container")[this.options.dialogWidget]("option","buttonApplyDisabled",false)}else{$("#"+this.grid.id()+"_updating_done").removeClass(this.css.buttonDisabled).attr("tabIndex",this._getNextTabIndex()+1)}},_updateTouchButtons:function(isAdding){var button=$("#"+this.grid.id()+"_updating_delete_touch");if(button.length){if(isAdding||!this.options.enableDeleteRow){button.addClass(this.css.buttonDisabled)}else{button.removeClass(this.css.buttonDisabled)}}},showDeleteButtonFor:function(row){var db=$("#"+this.grid.id()+"_updating_deletehover"),go=this.grid.options,v,hasHeight=go.height!==null&&go.height!==undefined,sbw=this.grid.hasVerticalScrollbar()===true?this.grid._scrollbarWidth():0,left,top,sc,offset=0,scrContainer,totalHeight,rowGrp=row.siblings("[data-id='"+row.attr("data-id")+"']").add(row);if(db.length){db.show();sc=db.parent();if(!hasHeight){v=go.virtualization||go.rowVirtualization||go.columnVirtualization;scrContainer=v?this.grid._vdisplaycontainer():this.grid.scrollContainer();if(scrContainer.length){offset=scrContainer.igPosition().top}}totalHeight=rowGrp.last().igPosition().top+rowGrp.last().outerHeight()-rowGrp.first().igPosition().top;left=sc.outerWidth()-db.outerWidth()-sbw+sc.scrollLeft()-5;top=rowGrp.first().igPosition().top+totalHeight/2-db.outerHeight()/2+sc.scrollTop()+offset;db.css({top:top,left:left});db.data("button-for",this._getRowId(row))}},hideDeleteButton:function(){var db=$("#"+this.grid.id()+"_updating_deletehover");if(db.length){db.hide()}},_getNextTabIndex:function(){var gti=this.grid.options.tabIndex;return gti+1},_getRowId:function(element){return this.grid._fixPKValue(element.attr("data-id"))},_getEditableElementsForRow:function(row){var result=[],i,cells=this._getEditableCellsForRow(row),editableCols=this._getEditableColsOrdered(),vcc=this.grid.hasFixedColumns()?this.grid._visibleColumns().length:this.grid._virtualColumnCount||this.grid._visibleColumns().length,vci=this.grid._startColIndex||0;for(i=0;i<editableCols.length;i++){result.push({colKey:editableCols[i].key,element:i>=vci&&i<vci+vcc?cells.eq(i-vci):null})}return result},_getEditableColsOrdered:function(){var ec,i,j;if(this.grid._isMultiRowGrid()){if(this._ec){return this._ec}ec=[];for(i=0;i<this.grid._rlp.length;i++){for(j=0;j<this.grid._rlp[i].length;j++){if(!this.grid._rlp[i][j].col.readOnly){ec.push(this.grid._rlp[i][j].col)}}}this._ec=ec;return ec}return $.grep(this.grid._visibleColumns(),function(col){return!col.readOnly})},_getColumnsOrderedByNavIndex:function(){var rwCols=$.extend(true,[],this._getEditableColsOrdered());rwCols.sort(function(a,b){return a.navigationIndex-b.navigationIndex});return rwCols},_getColumnByNavigationIndex:function(navIdx){var i;for(i=0;i<this.grid.options.columns.length;i++){if(this.grid.options.columns[i].navigationIndex===navIdx){return this.grid.options.columns[i]}}},_getEditedColumnElementsForRow:function(row){var result=[],cells,i;cells=this._getEditableCellsForRow(row).filter("."+this.css.editingCell);for(i=0;i<cells.length;i++){result.push({colKey:this._getColumnKeyForCell(cells.eq(i)),element:cells.eq(i)})}return result},_getEditedColumnElementsForDialog:function(content){var result=[],cols=this.grid.options.columns,i,key,element;for(i=0;i<cols.length;i++){key=cols[i].key;element=content.find("[data-editor-for-"+key.toLowerCase()+"]");if(element.length===1){result.push({colKey:key,element:element})}}return result},_getEditableCellsForRow:function(row){return this._combineRowElements(row).children("td[aria-readonly='false']:not([data-skip='true'],[data-parent])")},_combineRowElements:function(row){var frow,urow,fixingDir=this.grid.fixingDirection(),type=row.attr("data-new-row")?"[data-new-row]":"[data-add-row]";
if(this.grid.hasFixedColumns()){if(this.grid._isFixedElement(row)){frow=row;urow=row.parent().is("thead")?this.grid.headersTable().children("thead").children("tr"+type):this._getRowByIndex(this._getIndexForRow(row),false)}else{urow=row;frow=row.parent().is("thead")?this.grid.fixedHeadersTable().children("thead").children("tr"+type):this._getRowByIndex(this._getIndexForRow(row),true)}return fixingDir==="left"?$([frow[0],urow[0]]):$([urow[0],frow[0]])}return row},_getVisibleIndexForKey:function(columnKey){var vc=this.grid._visibleColumns(),i;for(i=0;i<vc.length;i++){if(vc[i].key===columnKey){return i}}return null},_getRowByIndex:function(index,fixed){var tbody=fixed?this.grid.fixedBodyContainer().find("tbody"):this.grid.element.find("tbody");return tbody.children("tr:not([data-container])").eq(index-(this.grid._startRowIndex||0))},_getIndexForRow:function(row){return row.closest("tbody").children("tr:not([data-container])").index(row)+(this.grid._startRowIndex||0)},_getColumnKeyForCell:function(cell){var col=this.grid.getColumnByTD(cell);return col?col.column.key:null},_analyzeEditTriggers:function(){var trg=this.options.startEditTriggers,key;this._editTriggers={click:false,dblclick:false,f2:false,enter:false};for(key in this._editTriggers){if(this._editTriggers.hasOwnProperty(key)){if($.type(trg)==="array"){this._editTriggers[key]=$.inArray(key,trg)}else{this._editTriggers[key]=trg.toLowerCase().indexOf(key)>=0}}}},_rebindEditTriggers:function(){var selector="#"+this.grid.id()+">tbody>tr>td,#"+this.grid.id()+"_fixed>tbody>tr>td",hId,scr,v,go=this.grid.options;if(this.options.enableAddRow&&go.showHeader){hId=this.grid.headersTable().attr("id");selector+=",#"+hId+">thead>tr.ui-iggrid-addrow,#"+hId+"_fixed>thead>tr.ui-iggrid-addrow"}this.grid.container().off(".triggers");this.grid.container().on({"mousedown.triggers":this._handlers.mouseDown,"touchstart.triggers":this._handlers.mouseDown},selector);if(this._editTriggers.dblclick){this.grid.container().on({"dblclick.triggers":this._handlers.clickTrigger},selector)}else if(this._editTriggers.click){this.grid.container().on({"click.triggers":this._handlers.clickTrigger},selector)}this.grid.container().on({"keydown.triggers":this._handlers.keyDown},selector.replace(/>td/g,""));if(this.options.enableDeleteRow){this._renderDeleteButton()}v=go.virtualization||go.rowVirtualization||go.columnVirtualization;scr=v?this.grid._vdisplaycontainer():this.grid.scrollContainer();if(scr&&scr.length){scr.unbind("scroll",this._handlers.scroll).bind("scroll",this._handlers.scroll)}},_getLatestValues:function(id,columnKey){var original,record,transactions,i,notNew=false;original=this.grid.dataSource.findRecordByKey(id);record=$.extend(true,{},original);transactions=this.grid.dataSource.pendingTransactions();for(i=0;i<transactions.length;i++){if(transactions[i].rowId===id){switch(transactions[i].type){case"row":case"newrow":case"insertnode":$.extend(true,record,transactions[i].row);break;case"cell":record[transactions[i].col]=transactions[i].value;break;case"deleterow":record=null;break}notNew=true}}if(original||notNew){this._origRec=record;return $.type(columnKey)==="string"?record[columnKey]:record}throw new Error(this._getLocaleValue("recordOrPropertyNotFoundException"))},_getDefaultValues:function(columnKey){var defVals=this._defaultValues,allValues,settings=this.options.columnSettings,i,gpkArgs;if(!defVals){defVals={};for(i=0;i<settings.length;i++){if(settings[i].defaultValue!==undefined&&$.type(settings[i].columnKey)==="string"){defVals[settings[i].columnKey]=settings[i].defaultValue}}this._defaultValues=defVals}allValues=$.extend(true,{},defVals);if((!columnKey||columnKey===this.grid.options.primaryKey)&&!defVals.hasOwnProperty(columnKey)){gpkArgs={owner:this};if(this._getPKType()==="string"){gpkArgs.value=String(this._pkVal)}else{gpkArgs.value=this._pkVal}this._trigger(this.events.generatePrimaryKeyValue,null,gpkArgs);allValues[this.grid.options.primaryKey]=gpkArgs.value}return columnKey?allValues[columnKey]:allValues},_getPKType:function(){var pk=this.grid.options.primaryKey,pkType,pkColumn,data=this.grid.dataSource._data;if(!this._pkt){if(!pk){throw new Error(this._getLocaleValue("noPrimaryKeyException"))}pkColumn=this.grid.columnByKey(pk);if(pkColumn&&pkColumn.dataType){pkType=pkColumn.dataType}else{pkType=data&&data.length>0&&data[0][pk]!==null&&data[0][pk]!==undefined?$.type(data[0][pk]):null}this._pkt=pkType}return this._pkt},_updateUIForTransaction:function(t,element){var go=this.grid.options,autoCommit=go.autoCommit,v=go.virtualization||go.rowVirtualization||go.columnVirtualization,fv=go.virtualizationMode==="fixed",row,vals,pk,groupBy,grp,idx,nextRow,rowHeight,dataRows;switch(t.type){case"newrow":if(this.grid.element.children("tbody").children("tr."+this.grid.css.modifiedRecord+"[data-id='"+t.rowId+"']").length){return}groupBy=this.grid.element.data("igGridGroupBy");grp=groupBy&&groupBy.options&&groupBy.options.groupedColumns&&groupBy.options.groupedColumns.length>0;this._updateUnboundValuesForRow(t.row);if(v&&!autoCommit){break}if(grp){this.grid.element.data("igGridGroupBy")._renderNewRow(t.row,t.rowId)}else{this.grid.renderNewRow(t.row,t.rowId)}this.grid._updateGridContentWidth();row=this.grid.rowById(t.rowId);if(!autoCommit&&row.length){this._combineRowElements(row).addClass(this.grid.css.modifiedRecord)}break;case"cell":pk=autoCommit&&t.col===go.primaryKey?t.value:t.rowId;if(element){row=element.parent();row=row.siblings("[data-id='"+row.attr("data-id")+"']").add(row)}else{row=this.grid.rowById(t.rowId)}vals=this._getLatestValues(pk);vals[t.col]=t.value;this._updateUnboundValuesForRow(vals);if(!row||!row.length){break}rowHeight=row.height();this.grid._renderRow(vals,row);if(autoCommit&&v&&rowHeight!==row.height()){this._updateRowVirtualization(row,fv,t.type)}if(!autoCommit){this._combineRowElements(row).addClass(this.grid.css.modifiedRecord)}else{this._combineRowElements(row).attr("data-id",pk).data("id",pk)}break;case"row":pk=autoCommit&&t.row.hasOwnProperty(go.primaryKey)?t.row[go.primaryKey]:t.rowId;row=element||this.grid.rowById(pk);vals=$.extend({},this._getLatestValues(pk),t.row);this._updateUnboundValuesForRow(vals);if(!row||!row.length){break}rowHeight=row.height();this.grid._renderRow(vals,row);if(autoCommit&&v&&rowHeight!==row.height()){this._updateRowVirtualization(row,fv,t.type)}if(!autoCommit){this._combineRowElements(row).addClass(this.grid.css.modifiedRecord)}else{this._combineRowElements(row).attr("data-id",pk).data("id",pk)}break;case"deleterow":row=element||this.grid.rowById(t.rowId);if(autoCommit&&v){this._updateRowVirtualization(row,fv,t.type);this._notifyRowDeleted(t.rowId,row);break}if(!row||!row.length){if(autoCommit){this._notifyRowDeleted(t.rowId,row)}break}if(autoCommit){dataRows=this.grid.element.children("tbody").children("tr:not([data-container],[data-grouprow],[data-summaryrow])");idx=dataRows.index(row);row=this._combineRowElements(row);nextRow=row.next("tr[data-container='true']");if(nextRow.length===1){nextRow.remove()}row.remove();this.grid._reapplyZebraStyle(idx);this.grid._updateGridContentWidth();this._notifyRowDeleted(t.rowId,row)}else{this._combineRowElements(row).addClass(this.grid.css.deletedRecord)}break}return row},_processReadOnly:function(){var i,col,cols=this.grid.options.columns,colSettings=this.options.columnSettings;delete this._ec;for(i=0;i<cols.length;i++){delete cols[i].readOnly}if(colSettings){for(i=0;i<colSettings.length;i++){col=this.grid.columnByKey(colSettings[i].columnKey);if(col&&col.readOnly!==colSettings[i].readOnly){col.readOnly=colSettings[i].readOnly}}}},_isMultiLineText:function(key){var cs=this._getColSettingsForCol(key);if(cs&&cs.editorOptions){return cs.editorOptions.textMode==="multiline"}return false},_anyEditorInvalid:function(){var key,all=this._editors,provider;for(key in all){if(all.hasOwnProperty(key)&&all[key]){provider=all[key].data("igEditorFilter").options.provider;provider.refreshValue();if(!all[key].data("igEditorFilter").options.provider.validate()){return true}}}return false},_revertValueForEditor:function(provider,columnKey){var oval,nval,ac,hf;provider.refreshValue();nval=provider.getValue();oval=this._originalValues[columnKey];hf=$.type(provider.editor.field)==="function";if(hf){ac=provider.editor.field().attr("autocomplete");provider.editor.field().attr("autocomplete","off")}if($.type(nval)==="date"&&$.type(oval)==="date"){if(nval.getTime()!==oval.getTime()){provider.setValue(new Date(oval.getTime()),true);if(hf){if(ac){provider.editor.field().removeAttr("autocomplete")}else{provider.editor.field().attr("autocomplete",ac)}}return true}}else if(oval!==nval){provider.setValue(oval,true);if(hf){if(ac){provider.editor.field().removeAttr("autocomplete")}else{provider.editor.field().attr("autocomplete",ac)}}return true}if(hf){if(ac){provider.editor.field().removeAttr("autocomplete")}else{provider.editor.field().attr("autocomplete",ac)}}return false},_hideValidatorMessages:function(){var key,e=this._editors,wrapper,validator;for(key in e){if(e.hasOwnProperty(key)){wrapper=this._providerForKey(key).data("igEditorFilter");if(wrapper&&wrapper.hasInvalidMessage()){validator=wrapper.options.provider.validator();if(validator){validator.hide()}}}}},_chooseColumnToFocus:function(isAdding,initialKey){var defaultIndex,i,columnToFocus,visibleCols=this.grid._visibleColumns(),vcc=this.grid._virtualColumnCount||visibleCols.length,vci=this.grid._startColIndex||0;defaultIndex=isAdding?0:this._getVisibleIndexForKey(initialKey);defaultIndex=Math.min(Math.max(vci,defaultIndex),vci+vcc-1);if(!initialKey){defaultIndex--}if(initialKey&&!this.grid.columnByKey(initialKey).readOnly){columnToFocus=initialKey}else{i=defaultIndex+1<visibleCols.length?defaultIndex+1:vci;while(visibleCols[i].key!==initialKey){if(!visibleCols[i].readOnly){columnToFocus=visibleCols[i].key;break}if(++i===vci+vcc){i=vci}}}return columnToFocus},_chooseColumnToFocusMrl:function(isAdding,initialKey){var cols=this._getColumnsOrderedByNavIndex(),col,targetNavIndex=0,i=0,rolledBack=false;if(isAdding){return cols?cols[0].key:null}if(initialKey){col=this.grid.columnByKey(initialKey);if(!col.readOnly){return initialKey}targetNavIndex=col.navigationIndex}while(i<cols.length){if(cols[i].navigationIndex>=targetNavIndex){return cols[i].key}i++;if(i===cols.length&&!rolledBack){i=0;rolledBack=true}}},_addDSSuccessHandler:function(){var fS,grid=this.grid;if(this._addChangesSuccessHandler!==null&&this._addChangesSuccessHandler!==undefined){grid.dataSource._removeChangesSuccessHandler(this._addChangesSuccessHandler)}fS=this.options.saveChangesSuccessHandler;if(fS){if($.type(fS)==="string"&&window[fS]&&$.type(window[fS])==="function"){fS=window[fS]}}if($.type(fS)!=="function"){fS=null}this._addChangesSuccessHandler=function(data){if(grid.rows().parent().find("."+grid.css.deletedRecord).length){grid._renderData()}grid.rows().removeClass(grid.css.modifiedRecord);if(fS){fS(data)}};grid.dataSource._addChangesSuccessHandler(this._addChangesSuccessHandler)},_addDSErrorHandler:function(){var fE;if(this._addChangesErrorHandler!==null&&this._addChangesErrorHandler!==undefined){this.grid.dataSource._removeChangesErrorHandler(this._addChangesErrorHandler)}if(this.options.saveChangesErrorHandler){fE=this.options.saveChangesErrorHandler;if($.type(fE)==="string"&&window[fE]&&$.type(window[fE])==="function"){fE=window[fE]}if($.type(fE)==="function"){this._addChangesErrorHandler=function(jqXHR,textStatus,errorThrown){fE(jqXHR,textStatus,errorThrown)};this.grid.dataSource._addChangesErrorHandler(this._addChangesErrorHandler)}}},_resolveRowElement:function(element,rowId){if(element){if(element.is("tr")){return element}if(element.is("td")&&(element.hasClass("ui-iggrid-addrow")||rowId===null)){if(element.parent().attr("data-new-row")){return element.parent().parent().children("[data-new-row]")}else{return element.parent()}}}return this.grid.rowById(rowId)},_updateRowVirtualization:function(row,fixed,type){var svst;if(fixed&&type==="deleteRow"){if(this.grid._startRowIndex+this.grid._virtualRowCount===this.grid._totalRowCount){this.grid._startRowIndex=Math.max(0,this.grid._startRowIndex-1)}this.grid._totalRowCount--;if(this.grid._virtualRowCount>this.grid._totalRowCount){this._virtPreRender(null,{owner:this.grid});this.grid._buildVirtualDom();this._virtPostRender(null,{owner:this.grid})}else{this.grid._renderVirtualRecords();this.grid._setScrollContainerHeight(this.grid._totalRowCount*parseInt(this.grid.options.avgRowHeight,10))}}else{svst=this.grid._persistVirtualScrollTop;this.grid._persistVirtualScrollTop=true;this.grid._saveFirstVisibleTRIndex();this.grid._renderVirtualRecords();this.grid._persistVirtualScrollTop=svst}},_childrenWithAddRowEnabled:function(opts,inheritedRule){var i,j,cl,clr;if(opts.columnLayouts){for(i=0;i<opts.columnLayouts.length;i++){cl=opts.columnLayouts[i];if(inheritedRule!==null&&inheritedRule!==undefined){clr=inheritedRule}else{clr=$.ui.igGridUpdating.prototype.options.enableAddRow}if(cl.features&&cl.features.length>0){for(j=0;j<cl.features.length;j++){if(cl.features[j].name==="Updating"){return cl.features[j].enableAddRow===null||cl.features[j].enableAddRow===undefined?clr:cl.features[j].enableAddRow}}}else{return inheritedRule===true}}}return false},_recOrPropFound:function(rowId,colKey){var pendingTransactions=this.grid.dataSource.pendingTransactions(),rec,i=pendingTransactions.length,found,hasUnboundValue;rec=this.grid.dataSource.findRecordByKey(rowId);found=!!rec;if(colKey){hasUnboundValue=this.grid._unboundValues&&this.grid._unboundValues.hasOwnProperty(colKey);found=found&&(rec.hasOwnProperty(colKey)||hasUnboundValue)}if(!found){while(--i>=0){if(pendingTransactions[i].rowId===rowId){return colKey?pendingTransactions[i].row.hasOwnProperty(colKey):true}}return false}return true},_activateEditor:function(editor){var cell=editor.closest("td");if(cell.length&&this.options.editMode!=="dialog"){this._scrollTo(cell)}editor.igEditorFilter("setFocus");setTimeout(function(){if(editor.data("igEditorFilter")){editor.igEditorFilter("setFocus")}},5)},_scrollTo:function(cell){var gOpts=this.grid.options,v=gOpts.virtualization||gOpts.rowVirtualization||gOpts.columnVirtualization,scrollContainer=v?this.grid._vdisplaycontainer():this.grid.scrollContainer(),cellPosition,ct,cl,paddingRight;if(scrollContainer.length&&scrollContainer.has(cell).length){cellPosition=cell.igPosition();paddingRight=this.grid.element.find("tbody > tr:first > :last-child").attr("data-vscr-padding-icrement");paddingRight=paddingRight&&!cell.is(":last-child")?parseInt(paddingRight,10):0;ct=cellPosition.top+scrollContainer.scrollTop();cl=cell.igOffset().left-cell.offsetParent().igOffset().left+scrollContainer.scrollLeft();if(cellPosition.left<0){scrollContainer.scrollLeft(cl)}else if(cl+cell.outerWidth()+paddingRight>scrollContainer.scrollLeft()+scrollContainer.outerWidth()){scrollContainer.scrollLeft(cl+cell.outerWidth()+paddingRight-scrollContainer.outerWidth())}if(cellPosition.top<0){scrollContainer.scrollTop(ct)}else if(ct+cell.outerHeight()>scrollContainer.scrollTop()+scrollContainer.outerHeight()){scrollContainer.scrollTop(ct+cell.outerHeight()-scrollContainer.outerHeight())}}},_setScroll:function(code,nextActiveElement){var scrollVDir=code===$.ui.keyCode.DOWN||code===$.ui.keyCode.RIGHT?"down":"up";this._setScrollTop(this.grid.element.parent(),nextActiveElement.closest("tr"),scrollVDir,nextActiveElement.closest("tr").index()+(this.grid._startRowIndex||0))},_setScrollTop:function(parent,child,direction,index){var parentOffset=parent.igOffset(),childOffset=child.igOffset(),childh,isDown,isUp,v,c;if(!child||child.length===0){return}v=this.grid.options.virtualization||this.grid.options.rowVirtualization;c=v&&this.grid.options.virtualizationMode==="continuous";childh=v&&!c?parseInt(this.grid.options.avgRowHeight,10):child.outerHeight();if(!v||c){isDown=childOffset.top+childh+this.grid._scrollbarWidth()>parentOffset.top+$(parent).outerHeight();isUp=childOffset.top-childh/2<=parentOffset.top||c&&index<0}if(index===0&&(!v||c)){parent[0].scrollTop=0}else if(direction==="down"){if(isDown){if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}}}else{if(isUp){if(c){this.grid._onVirtualVerticalScroll({},childh,direction)}}}},_scrollVmanual:function(down){var sc=$("#"+this.grid.element[0].id+"_scrollContainer"),h=parseInt(this.grid.options.avgRowHeight,10);this.grid._ignoreScroll=true;if(down){sc.scrollTop(sc.scrollTop()+h)}else{sc.scrollTop(sc.scrollTop()-h)}this.grid._onVirtualVerticalScroll();this.grid._ignoreScroll=false;this._vscrolled=true},_deleteRow:function(evt,rowId,suppress){var arg,t,autoCommit=this.grid.options.autoCommit,row=this.grid.rowById(rowId);if(row.hasClass(this.grid.css.deletedRecord)){return}arg={owner:this,element:row,rowID:rowId};if(!suppress){if(!this._trigger(this.events.rowDeleting,evt,arg)){return false}}t=this.grid.dataSource.deleteRow(rowId,autoCommit);row=this._updateUIForTransaction(t,row);if(!suppress){this._trigger(this.events.rowDeleted,evt,arg)}return true},_deleteMultipleRows:function(evt){var selectedRows=this.grid.element.igGridSelection("selectedRows"),i;for(i=0;i<selectedRows.length;i++){if(selectedRows[i]&&selectedRows[i].hasOwnProperty("id")&&!selectedRows[i].element.hasClass(this.grid.css.deletedRecord)){this._deleteRow(evt,selectedRows[i].id,false)}}},_updateRow:function(rowId,updateObj,origObj,row){var t,autoCommit=this.grid.options.autoCommit,i,extendedObj,key,colLaytout=this.grid.options.columnLayouts;origObj=origObj||this._getLatestValues(rowId);row=row||this.grid.rowById(rowId);extendedObj=$.extend({},origObj,updateObj);if(colLaytout){for(i=0;i<colLaytout.length;i++){key=colLaytout[i].key;delete extendedObj[key]}}t=this.grid.dataSource.updateRow(rowId,extendedObj,autoCommit);this._updateUIForTransaction(t,row);this._notifyRowUpdated(rowId,row)},_updateCell:function(rowId,colKey,value,cell){var t,autoCommit=this.grid.options.autoCommit;t=this.grid.dataSource.setCellValue(rowId,colKey,value,autoCommit);this._updateUIForTransaction(t,cell);this._notifyCellUpdated(rowId,cell)},_addRow:function(evt,addObj,defVals,suppress){var arg,key,t,row,fk=this.grid.options.foreignKey,ds=this.grid.dataSource,sl,go=this.grid.options,isVirtualGrid=go.virtualization||go.rowVirtualization||go.columnVirtualization,container=isVirtualGrid?this.grid._vdisplaycontainer():this.grid.scrollContainer();addObj=$.extend({},defVals,addObj);arg={owner:this,values:addObj,oldValues:defVals};if(!suppress){if(!this._trigger(this.events.rowAdding,evt,arg)){return false}}key=addObj[this.grid.options.primaryKey];if(key===undefined||key===null){key=this._pkVal;addObj[this.grid.options.primaryKey]=key}else{if(fk&&!addObj.hasOwnProperty(fk)){if(ds._origDs&&ds._origDs.length&&ds._origDs[0].hasOwnProperty(fk)){addObj[fk]=ds._origDs[0][fk]}else if(this.grid.options.foreignKeyValue!==null&&this.grid.options.foreignKey!==undefined){addObj[fk]=this.grid.options.foreignKeyValue}else{addObj[fk]=null}}}t=this.grid.dataSource.addRow(key,addObj,this.grid.options.autoCommit);row=this._updateUIForTransaction(t);this._notifyRowAdded(row);sl=container.data("igScroll");if(sl&&!isVirtualGrid){sl._scrollTop(this.element.height()-container.height())}if($.type(this._pkVal)==="number"){this._pkVal++}if(!suppress){this._trigger(this.events.rowAdded,evt,arg)}},_notifyRowAdded:function(row){var container,sl,isVirtualGrid=false,go=this.grid.options,rs=this.grid.element.data("igGridRowSelectors"),pa=this.grid.element.data("igGridPaging"),su=this.grid.element.data("igGridSummaries");if(go.virtualization||go.rowVirtualization||go.columnVirtualization){container=this.grid._vdisplaycontainer();isVirtualGrid=true}else{container=this.grid.scrollContainer()}if(rs&&typeof rs._rowAdded==="function"){rs._rowAdded(row)}if(pa&&typeof pa._rowAdded==="function"){pa._rowAdded(row)}if(su&&typeof su._rowAdded==="function"){su._rowAdded(row)}sl=container.data("igScroll");if(sl){if(isVirtualGrid){this.grid._enableVirtualTouchScrollbars()}else{this.grid._enableTouchScrollbars()}}this.grid._fireInternalEvent("_internalRowAdded",{row:row})},_notifyRowDeleted:function(rowId,element){var container,sl,isVirtualGrid=false,go=this.grid.options,se=this.grid.element.data("igGridSelection"),pa=this.grid.element.data("igGridPaging"),su=this.grid.element.data("igGridSummaries");if(go.virtualization||go.rowVirtualization||go.columnVirtualization){container=this.grid._vdisplaycontainer();isVirtualGrid=true}else{container=this.grid.scrollContainer()}if(se&&typeof se._rowDeleted==="function"){se._rowDeleted(rowId,element)}if(su&&typeof su._rowDeleted==="function"){su._rowDeleted(rowId,element)}if(pa&&typeof pa._rowDeleted==="function"){pa._rowDeleted(rowId,element)}sl=container.data("igScroll");if(sl){if(isVirtualGrid){this.grid._enableVirtualTouchScrollbars()}else{this.grid._enableTouchScrollbars();sl._scrollTop(sl._getContentPositionY())}}this.grid._fireInternalEvent("_internalRowDeleted",{rowID:rowId,row:element})},_notifyCellUpdated:function(rowId,cell){this.grid._fireInternalEvent("_internalCellUpdated",{rowID:rowId,cell:cell})},_notifyRowUpdated:function(rowId,row){this.grid._fireInternalEvent("_internalRowUpdated",{rowID:rowId,row:row})},_renderRowEditDialog:function(rerender){var opts=this.options.rowEditDialogOptions,container,containment,captionsContainer,closeButton,dialogSelector="#"+this.grid.id()+"_updating_dialog_container",titleLabel=this._getLocaleValue("rowEditDialogCaptionLabel"),doneButtonLabel=this._getLocaleValue("doneLabel"),doneButtonTitle=this._getLocaleValue("doneTooltip"),cancelButtonLabel=this._getLocaleValue("cancelLabel"),cancelButtonTitle=this._getLocaleValue("cancelTooltip");container=$(dialogSelector);if(container.length){if(!rerender){return container}container[this.options.dialogWidget]("destroy");container.remove();this._destroyAllEditors()}if(opts.containment==="owner"){containment=this.grid._rootContainer()}else{containment="window"}container=$("<div></div>").appendTo(this.grid._rootContainer()).attr("id",dialogSelector.substring(1));container[this.options.dialogWidget]({containment:containment,renderFooterButtons:opts.showDoneCancelButtons,modalDialogWidth:opts.width,modalDialogHeight:opts.height,locale:{modalDialogCaptionText:titleLabel,buttonApplyText:doneButtonLabel,buttonApplyTitle:doneButtonTitle,buttonCancelText:cancelButtonLabel,buttonCancelTitle:cancelButtonTitle},animationDuration:opts.animationDuration,buttonApplyDisabled:true,gridContainer:this.grid._rootContainer(),closeModalDialogOnEnter:true,modalDialogOpening:this._dialogHandlers.dialogOpening,modalDialogOpened:this._dialogHandlers.dialogOpened,modalDialogClosing:this._dialogHandlers.dialogClosing,modalDialogClosed:this._dialogHandlers.dialogClosed,buttonOKClick:this._dialogHandlers.dialogDone,buttonCancelClick:this._dialogHandlers.dialogCancel,tabIndex:this._getNextTabIndex()});captionsContainer=container[this.options.dialogWidget]("getCaptionButtonContainer");closeButton=$("<button type='button'></button>").attr("id",this.grid.id()+"_updating_dialog_closeButton").attr("tabindex",this._getNextTabIndex()).appendTo(captionsContainer);closeButton.igButton({onlyIcons:true,icons:{primary:this.css.rowEditDialogCloseButton},width:"20px",height:"20px",click:this._dialogHandlers.dialogCloseClick});this._dialogInvalid=false;this._editorsContainerInvalid=true;this._trigger(this.events.rowEditDialogContentsRendered,null,{owner:this,dialogElement:container});return container},_renderDialogContent:function(content,values){var opts=this.options.rowEditDialogOptions,colgroup,tmpl;this._clearEditorsFromContainer(content);content.empty();if(opts.dialogTemplateSelector){tmpl=$(opts.dialogTemplateSelector);content.append($(this._jsr?tmpl.render(values):$.ig.tmpl(tmpl.html().fullTrim(),values)))}else if(opts.dialogTemplate){tmpl=opts.dialogTemplate;content.append($(this._jsr?$.render[this.grid.id()+"_rowEditDialogTemplate"](values):$.ig.tmpl(tmpl,values)))}else{content.html(this._defaultDialogTemplate);content.find("table").addClass(this.css.rowEditDialogTable).css("table-layout","fixed");colgroup=content.find("colgroup");colgroup.children(":first").css("width",opts.namesColumnWidth);colgroup.children(":last").css("width",opts.editorsColumnWidth);colgroup.parent().css("width","100%")}},_renderDialogTemplate:function(tmplParent,cols,onlyVisible){var opts=this.options.rowEditDialogOptions,tmpl,i,tr,e;cols=onlyVisible?$.grep(cols,function(col){return!col.hidden}):cols;if(!opts.showReadonlyEditors){cols=$.grep(cols,function(col){return!col.readOnly})}if(opts.editorsTemplateSelector){tmpl=$(opts.editorsTemplateSelector);tmplParent.append($(this._jsr?tmpl.render(cols):$.ig.tmpl(tmpl.html().fullTrim(),cols)))}else if(opts.editorsTemplate){tmpl=opts.editorsTemplate;tmplParent.append($(this._jsr?$.render[this.grid.id()+"_rowEditDialogEditorsTemplate"](cols):$.ig.tmpl(tmpl,cols)))}else{for(i=0;i<cols.length;i++){tr=$("<tr></tr>");$("<td>"+(cols[i].headerText||cols[i].key)+"</td>").appendTo(tr);$("<td></td>").appendTo(tr);e=this._isMultiLineText(cols[i].key)?$("<textarea></textarea>"):$("<input />");e.attr("data-editor-for-"+cols[i].key,"").appendTo(tr.children(":last"));tr.appendTo(tmplParent)}}},_initDialogEditors:function(content,cols,values){var i=0,provider,providerWrapper,ro,key,element,val,settings;this._editors=this._editors||{};while(i<cols.length){key=cols[i].key;ro=!!cols[i].readOnly;val=values[key]===undefined?null:values[key];element=content.find("[data-editor-for-"+key.toLowerCase()+"]");if(element.length===1){providerWrapper=this._providerForKey(key);if(providerWrapper&&providerWrapper.has(element).length){provider=providerWrapper.igEditorFilter("option","provider");provider.setValue(val,false,this.grid._calcOffsetForCol(this._origRec,cols[i],true))}else{if(ro){settings=this._getColSettingsForCol(key);if(!settings){this.options.columnSettings.push({columnKey:key,editorOptions:{readOnly:true}})}else{$.extend(true,settings,{editorOptions:{readOnly:true}})}}providerWrapper=this._createEditor(null,key,element);this._editors[key]=providerWrapper;provider=providerWrapper.igEditorFilter("option","provider");provider.setValue(val,false,this.grid._calcOffsetForCol(this._origRec,cols[i],true))}if(this._columnToFocus===key){this._columnToFocus=providerWrapper}this._originalValues=this._originalValues||{};this._originalValues[key]=provider.getValue();$.ig.removeFromArray(cols,i,i)}else{i++}}},_clearEditorsFromContainer:function(content){var cols=this.grid.options.columns,i=-1,key,element,providerWrapper;while(++i<cols.length){key=cols[i].key;element=content.find("[data-editor-for-"+key.toLowerCase()+"]");if(element.length){providerWrapper=this._providerForKey(key).data("igEditorFilter");if(providerWrapper){this._providerForKey(key).igEditorFilter("destroy");delete this._editors[key]}}}},_renderDoneCancelButtons:function(){var buttonContainer,buttonsParent,doneButton,cancelButton,deleteButton,doneButtonLabel=this._getLocaleValue("doneLabel"),doneButtonTitle=this._getLocaleValue("doneTooltip"),cancelButtonLabel=this._getLocaleValue("cancelLabel"),cancelButtonTitle=this._getLocaleValue("cancelTooltip"),doneSelector,cancelSelector,deleteSelector,v=this.grid.options.virtualization===true||this.grid.options.columnVirtualization===true||this.grid.options.rowVirtualization===true,sbw=this.grid.hasVerticalScrollbar()&&!v?this.grid._scrollbarWidth():0;buttonContainer=$("<div></div>").css("position","absolute").attr("unselectable","on").addClass(this.css.buttonContainer);buttonsParent=this._addElementToScrollContainer(buttonContainer);doneButton=$("<span></span").attr("id",this.grid.id()+"_updating_done").addClass(this.css.button).addClass(this.css.doneButton).attr({unselectable:"on",tabIndex:this._getNextTabIndex()+1,title:doneButtonTitle,"data-localeid":"doneTooltip","data-localeattr":"title"}).css({display:"inline-block",position:"relative"}).appendTo(buttonContainer);$("<span></span>").css("display","inline-block").addClass(this.css.doneIcon).attr("unselectable","on").appendTo(doneButton);if(doneButtonLabel&&doneButton.length){$("<span></span>").css("display","inline-block").attr({unselectable:"on","data-localeid":"doneLabel"}).html(doneButtonLabel).appendTo(doneButton)}else{doneButton.addClass(this.css.buttonIconOnly)}cancelButton=$("<span></span>").attr("id",this.grid.id()+"_updating_cancel").addClass(this.css.button).addClass(this.css.cancelButton).attr({unselectable:"on",tabIndex:this._getNextTabIndex()+1,title:cancelButtonTitle,"data-localeid":"cancelTooltip","data-localeattr":"title"}).css({display:"inline-block",position:"relative"}).appendTo(buttonContainer);$("<span></span>").css("display","inline-block").addClass(this.css.cancelIcon).attr("unselectable","on").appendTo(cancelButton);if(cancelButtonLabel&&cancelButtonLabel.length){$("<span></span>").css("display","inline-block").attr({unselectable:"on","data-localeid":"cancelLabel"}).html(cancelButtonLabel).appendTo(cancelButton)}else{cancelButton.addClass(this.css.buttonIconOnly)}if(this._renderTouchUI&&this.options.enableDeleteRow){deleteButton=$("<span />").attr("id",this.grid.id()+"_updating_delete_touch").addClass(this.css.button).addClass(this.css.doneButton).attr({unselectable:"on",tabIndex:this._getNextTabIndex()+1,title:this._getLocaleValue("deleteRowTooltip"),"data-localeid":"deleteRowTooltip","data-localeattr":"title"}).prependTo(buttonContainer);$("<span />").css({display:"inline-block",left:0}).addClass(this.css.deleteIcon).attr("unselectable","on").appendTo(deleteButton);$("<span />").css("display","inline-block").attr({unselectable:"on","data-localeid":"deleteRowLabel"}).html(this._getLocaleValue("deleteRowLabel")).appendTo(deleteButton);deleteButton.css({"float":"left",position:"relative"});doneButton.css("float","right");cancelButton.css("float","right");buttonContainer.css("width",buttonsParent.outerWidth()-sbw-2);deleteSelector="#"+deleteButton.attr("id")}doneSelector="#"+doneButton.attr("id");cancelSelector="#"+cancelButton.attr("id");this.grid.container().on({"mouseenter.donecancel":this._buttonHandlers.mouseEnter,"mouseleave.donecancel":this._buttonHandlers.mouseLeave,"focus.donecancel":this._buttonHandlers.focus,"blur.donecancel":this._buttonHandlers.blur},doneSelector+","+cancelSelector+(deleteSelector?","+deleteSelector:""));this.grid.container().on({"click.donecancel":this._buttonHandlers.doneClick,"keyup.donecancel":this._buttonHandlers.doneKeyUp,"keydown.donecancel":this._buttonHandlers.doneKeyDown},doneSelector);this.grid.container().on({"click.donecancel":this._buttonHandlers.cancelClick,"keyup.donecancel":this._buttonHandlers.cancelKeyUp,"keydown.donecancel":this._buttonHandlers.cancelKeyDown},cancelSelector);if(deleteSelector){this.grid.container().on({"click.donecancel":this._buttonHandlers.touchDeleteClick,"keyup.donecancel":this._buttonHandlers.touchDeleteKeyUp},deleteSelector)}return buttonContainer},_removeDoneCancelButtons:function(){var container=this._findElementInScrollContainer(".ui-iggrid-buttoncontainer:first");this.grid.container().off(".donecancel");container.remove()},_renderDeleteButton:function(){var deleteButton,deleteParent,ubodySelector="#"+this.grid.id()+">tbody",fbodySelector="#"+this.grid.id()+"_fixed>tbody",deleteSelector="#"+this.grid.id()+"_updating_deletehover",deleteButtonTitle=this._getLocaleValue("deleteRowTooltip"),pe=window.navigator.pointerEnabled;deleteButton=$(deleteSelector);if(deleteButton.length){return}deleteButton=$("<span></span>").attr("id",deleteSelector.substring(1)).css("position","absolute").addClass(this.css.deleteButton).attr({unselectable:"on",title:deleteButtonTitle,"data-localeid":"deleteRowTooltip","data-localeattr":"title"});deleteButton.hide();$("<span></span>").css("display","inline-block").addClass(this.css.deleteIcon).attr("unselectable","on").appendTo(deleteButton);deleteParent=this._addElementToScrollContainer(deleteButton);this.grid.container().on({"mouseenter.deletebutton":this._buttonHandlers.mouseEnter,
"mouseleave.deletebutton":this._buttonHandlers.mouseLeave,"click.deletebutton":this._buttonHandlers.deleteClick,"keyup.deletebutton":this._buttonHandlers.deleteClick},deleteSelector);if(pe){this.grid.container().on({"pointerover.deletebutton":this._handlers.pointerEnter},ubodySelector+">tr,"+fbodySelector+">tr")}else{this.grid.container().on({"mouseenter.deletebutton":this._handlers.mouseEnter},ubodySelector+">tr,"+fbodySelector+">tr")}this.grid.container().on({"MSPointerDown.deletebutton":this._handlers.pointerDown,"pointerdown.deletebutton":this._handlers.pointerDown,"MSPointerUp.deletebutton":this._handlers.pointerUp,"pointerup.deletebutton":this._handlers.pointerUp,"touchstart.deletebutton":this._handlers.touchStart,"touchend.deletebutton":this._handlers.touchEnd},ubodySelector+">tr,"+fbodySelector+">tr");if(deleteParent[0]===this.grid.container()[0]){if(pe){this.grid.container().bind("pointerleave.deletebutton",this._handlers.pointerLeave)}else{this.grid.container().bind("mouseleave.deletebutton",this._handlers.mouseLeave)}}else{if(pe){this.grid.container().on({"pointerleave.deletebutton":this._handlers.pointerLeave},"#"+deleteParent.attr("id"))}else{this.grid.container().on({"mouseleave.deletebutton":this._handlers.mouseLeave},"#"+deleteParent.attr("id"))}}},_removeDeleteButton:function(){$("#"+this.grid.id()+"_updating_deletehover").remove();this.grid.container().off(".deletebutton");this.grid.container().unbind(".deletebutton")},_renderAddNewRow:function(thead){var addRowLabel=this._getLocaleValue("addRowLabel"),addRowTitle=this._getLocaleValue("addRowTooltip"),addTr,newTr,mainTd,i,recVerticalSize;addTr=thead.children("tr[data-add-row='true']");if(!addTr.length){addTr=$("<tr></tr>").addClass(this.css.addRow).attr({"data-add-row":true,tabIndex:this.grid.options.tabIndex}).appendTo(thead)}addTr.empty();mainTd=$("<td></td>").attr({title:addRowTitle,"data-localeid":"addRowTooltip","data-localeattr":"title"}).addClass(this.css.addRow).appendTo(addTr);$("<span></span>").css("display","inline-block").addClass(this.css.addRowIcon).appendTo(mainTd);$("<span></span>").text(addRowLabel).css("outline",0).attr({tabIndex:0,"data-localeid":"addRowLabel"}).appendTo(mainTd);newTr=thead.children("tr[data-new-row='true']");if(!newTr.length){recVerticalSize=this.grid._recordVerticalSize();for(i=0;i<recVerticalSize;i++){$("<tr></tr>").attr("data-new-row","true").attr("data-role","newrow").appendTo(thead).hide()}}},_generateDummyLayout:function(cols){var i,layout=[[]];for(i=0;i<cols.length;i++){layout[0].push({col:cols[i],rs:1,cs:1})}return layout},_addElementToScrollContainer:function(element){var go=this.grid.options,container,hasHeight=go.height!==null&&go.height!==undefined;if(!hasHeight){container=this.grid.container();element.appendTo(container)}else if(this.grid.hasFixedColumns()&&this.grid.fixingDirection()==="right"){container=this.grid.fixedBodyContainer();element.prependTo(container)}else{if(go.virtualization||go.rowVirtualization||go.columnVirtualization){container=this.grid._vdisplaycontainer()}else{container=this.grid.scrollContainer()}element.prependTo(container)}return container},_findElementInScrollContainer:function(selector){var go=this.grid.options,container,hasHeight=go.height!==null&&go.height!==undefined;if(!hasHeight){container=this.grid.container()}else if(this.grid.hasFixedColumns()&&this.grid.fixingDirection()==="right"){container=this.grid.fixedBodyContainer()}else{if(go.virtualization||go.rowVirtualization||go.columnVirtualization){container=this.grid._vdisplaycontainer()}else{container=this.grid.scrollContainer()}}return container.children(selector)},_createHandlers:function(){this._stopEditingHandler=this._stopEditingHandler||$.proxy(this._stopEditing,this);this._gridHandlers=this._gridHandlers||{stopEditing:this._stopEditingHandler,gridDataRendering:$.proxy(this._gridDataRendering,this),rowsRendered:$.proxy(this._rowsRendered,this),headerRendering:$.proxy(this._processReadOnly,this),headerRendered:$.proxy(this._headerRendered,this),rendered:$.proxy(this._headerRendered,this),virtualFrameChanging:$.proxy(this._virtPreRender,this),virtualFrameChanged:$.proxy(this._virtPostRender,this),columnsCollectionModified:$.proxy(this._columnsModified,this),columnsMoved:$.proxy(this._columnsMoved,this)};this._handlers=this._handlers||{mouseDown:$.proxy(this._mouseDown,this),clickTrigger:$.proxy(this._clickTrigger,this),keyDown:$.proxy(this._keyDown,this),focus:$.proxy(this._focus,this),blur:$.proxy(this._blur,this),touchStart:$.proxy(this._touchStart,this),touchEnd:$.proxy(this._touchEnd,this),pointerDown:$.proxy(this._pointerDown,this),pointerUp:$.proxy(this._pointerUp,this),mouseEnter:$.proxy(this._rowMouseEnter,this),pointerEnter:$.proxy(this._rowPointerEnter,this),mouseLeave:$.proxy(this._containerMouseLeave,this),pointerLeave:$.proxy(this._containerPointerLeave,this),scroll:$.proxy(this._scroll,this)};this._buttonHandlers=this._buttonHandlers||{mouseEnter:$.proxy(this._buttonMouseEnter,this),mouseLeave:$.proxy(this._buttonMouseLeave,this),focus:$.proxy(this._buttonFocus,this),blur:$.proxy(this._buttonBlur,this),doneClick:$.proxy(this._doneButtonClick,this),doneKeyUp:$.proxy(this._doneButtonKeyUp,this),doneKeyDown:$.proxy(this._doneButtonKeyDown,this),cancelClick:this._stopEditingHandler,cancelKeyUp:$.proxy(this._cancelButtonKeyUp,this),cancelKeyDown:$.proxy(this._cancelButtonKeyDown,this),deleteClick:$.proxy(this._deleteButtonClick,this),touchDeleteClick:$.proxy(this._touchDeleteButtonClick,this),touchDeleteKeyUp:$.proxy(this._touchDeleteButtonKeyUp,this)};this._addNewRowHandlers=this._addNewRowHandlers||{focus:$.proxy(this._addRowFocus,this),blur:$.proxy(this._addRowBlur,this)};this._validationHandlers=this._validationHandlers||{errorShowing:$.proxy(this._editorErrorShowing,this),errorShown:$.proxy(this._editorErrorShown,this),errorHidden:$.proxy(this._editorErrorHidden,this)};this._dialogHandlers=this._dialogHandlers||{dialogCloseClick:$.proxy(this._dialogCloseClick,this),dialogOpening:$.proxy(this._dialogOpening,this),dialogOpened:$.proxy(this._dialogOpened,this),dialogClosing:$.proxy(this._dialogClosing,this),dialogClosed:$.proxy(this._dialogClosed,this),dialogDone:$.proxy(this._dialogDone,this),dialogCancel:$.proxy(this._dialogCancel,this)};this._editorCallbacks=this._editorCallbacks||{keyDown:$.proxy(this._editorKeyDown,this),textChanged:$.proxy(this._editorTextChanged,this),valueChanged:$.proxy(this._editorTextChanged,this)}},_unbindAllEvents:function(){if(!this._gridHandlers){return}this.grid.element.off({"iggriduidirty.updating":this._gridHandlers.stopEditing,"ighierarchicalgridrowexpanded.updating":this._gridHandlers.stopEditing,"iggridrendered.updating":this._gridHandlers.gridRendered,"iggriddatarendering.updating":this._gridHandlers.gridDataRendering,"iggridrowsrendered.updating":this._gridHandlers.rowsRendered,"iggridvirtualrendering.updating":this._gridHandlers.virtualFrameChanging,"iggridvirtualrecordsrender.updating":this._gridHandlers.virtualFrameChanged,"iggridcolumnscollectionmodified.updating":this._gridHandlers.columnsCollectionModified,"iggridheaderrendering.updating":this._gridHandlers.headerRendering,iggriddatabinding:this._gridHandlers.gridDataRendering,"iggrid_columnsmoved.updating":this._gridHandlers.columnsMoved});if(this.options.enableAddRow){this.grid.element.off({"iggridheaderrenderedinternal.updating":this._gridHandlers.headerRendered,"iggridrendered.updating":this._gridHandlers.rendered})}this.grid.container().off({click:this._handlers.click})},_bindGridEvents:function(){this.grid.element.on({"iggriduidirty.updating":this._gridHandlers.stopEditing,"ighierarchicalgridrowexpanded.updating":this._gridHandlers.stopEditing,"iggriddatarendering.updating":this._gridHandlers.gridDataRendering,"iggridrowsrendered.updating":this._gridHandlers.rowsRendered,"iggridvirtualrendering.updating":this._gridHandlers.virtualFrameChanging,"iggridvirtualrecordsrender.updating":this._gridHandlers.virtualFrameChanged,"iggridcolumnscollectionmodified.updating":this._gridHandlers.columnsCollectionModified,"iggridheaderrendering.updating":this._gridHandlers.headerRendering,iggriddatabinding:this._gridHandlers.gridDataRendering,"iggrid_columnsmoved.updating":this._gridHandlers.columnsMoved});if(this.options.enableAddRow){this.grid.element.on({"iggridheaderrenderedinternal.updating":this._gridHandlers.headerRendered,"iggridrendered.updating":this._gridHandlers.rendered})}},_injectGrid:function(gridInstance,isRebind){var hg,cl,v;this.grid=gridInstance;v=this.grid.options.virtualization||this.grid.options.rowVirtualization||this.grid.options.columnVirtualization;this._addDSSuccessHandler();this._addDSErrorHandler();if(isRebind){return}this._dialogInvalid=true;this._defaultDialogTemplate="<table><colgroup><col></col><col></col></colgroup><tbody data-render-tmpl></tbody></table>";this._editors=this._editors||{};if(this.grid.options.virtualizationMode!=="continuous"&&(this.grid.options.virtualization===true&&this.grid.options.width||this.grid.options.columnVirtualization===true)&&this.options.editMode==="row"){throw new Error(this._getLocaleValue("rowUpdatingNotSupportedWithColumnVirtualization"))}if(this.options.excelNavigationMode&&(this.options.editMode!=="cell"&&this.options.editMode!=="row")){throw new Error(this._getLocaleValue("excelNavigationNotSupportedWithCurrentEditMode"))}if(this.grid.options.autoCommit===false&&v){throw new Error(this._getLocaleValue("virtualizationNotSupportedWithoutAutoCommit"))}this._createHandlers();this._bindGridEvents();this._analyzeEditTriggers();if(this.grid.options._isHierarchicalGrid&&this.grid._originalOptions){if(this.options.inherit){this.grid._shouldAlwaysRenderChildIndicator=this._childrenWithAddRowEnabled(this.grid.options,this.options.enableAddRow)}else{this.grid._shouldAlwaysRenderChildIndicator=this._childrenWithAddRowEnabled(this.grid.options)}if(!this.grid.dataSource.settings.schema.layouts){hg=this.grid.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");cl=[];hg._parseLayouts(cl,"",this.grid._originalOptions);this.grid.dataSource.settings.schema.layouts=cl}}this._renderTouchUI=$.ig.util.isTouch;if(window.navigator.msPointerEnabled||window.navigator.pointerEnabled){this.grid.element.css("-ms-touch-action","none");this.grid.element.css("touch-action","none")}if(String(this.grid.options.templatingEngine).toLowerCase()==="jsrender"){this._jsr=true;if(this.options.rowEditDialogOptions.dialogTemplate&&typeof this.options.rowEditDialogOptions.dialogTemplate==="string"){$.templates(this.grid.id()+"_rowEditDialogTemplate",this.options.rowEditDialogOptions.dialogTemplate)}if(this.options.rowEditDialogOptions.editorsTemplate&&typeof this.options.rowEditDialogOptions.editorsTemplate==="string"){$.templates(this.grid.id()+"_rowEditDialogEditorsTemplate",this.options.rowEditDialogOptions.editorsTemplate)}}}});$.extend($.ui.igGridUpdating,{version:"21.2.12"});return $});