﻿$IG.EditingCore=function(obj,objProps,control){$IG.EditingCore.initializeBase(this,[obj,objProps,control]);this._rowsToDelete=new $IG.GridAffectedItems();this._addRowCellValues=null;this._cellValueChangedListener=Function.createDelegate(this,this._cellValueChanged);control._gridUtil._registerEventListener(control,"CellValueChanged",this._cellValueChangedListener);this._onRowsDeletingListener=Function.createDelegate(this,this._onRowsDeleting);control._gridUtil._registerEventListener(control,"RowsDeleted",this._onRowsDeletingListener);this._onRowAddingListener=Function.createDelegate(this,this._onRowAdding);control._gridUtil._registerEventListener(control,"RowAdded",this._onRowAddingListener);};$IG.EditingCore.prototype={commit:function(){this._commitUpdates();this._commitDeletes();this._commitAdds();},_commitUpdates:function(){for(var actionKey in this._actions){var action=this._actions[actionKey];if(!action._commited){var row=action._object;var updatedCells=action.get_updatedCells();var eventArgs=new $IG.CancelUpdateRowEventArgs(this,row,updatedCells);if(this._clientEvents["RowUpdating"])this._owner._raiseSenderClientEventStart(this,this._clientEvents["RowUpdating"],eventArgs);if(!eventArgs.get_cancel()){action._commited=true;if(this._clientEvents["RowUpdating"])this._get_owner()._raiseClientEventEnd(eventArgs);}else{for(var i=0;i<updatedCells.get_length();i++){var change=updatedCells.getItem(i);var column=this._grid.get_columns().get_columnFromIDPair(change.colIdPair);var cell=row.get_cellByColumn(column);cell._set_value_internal(change.oldValue);}updatedCells.clear();}delete this._actions[actionKey];}}},_commitDeletes:function(){if(this._rowsToDelete.get_length()>0){var RowsDeletingEventArgs=new $IG.CancelRowsDeletingEventArgs(this,this._rowsToDelete);this._owner._raiseSenderClientEventStart(this,this._clientEvents["RowsDeleting"],RowsDeletingEventArgs);if(!RowsDeletingEventArgs.get_cancel()){rows=RowsDeletingEventArgs.get_rows();var numRows=rows.get_length();var row;var rowIdPairs=new Array();for(var i=numRows-1;i>=0;i--){row=rows.getItem(i);rowIdPairs[i]=row.get_idPair();}rowIdPairs.sort(this._sortRowIdPairs);if(this._selection){this._selection._selectedRowCollection.clear();this._selection._selectedCellCollection.clear();}this._get_owner()._actionList.add_transaction(new $IG.GridAction("DeleteRow","EditingCore",this._get_owner(),rowIdPairs));this._get_owner()._raiseClientEventEnd(RowsDeletingEventArgs);}else this._rowsToDelete.clear();}},_commitAdds:function(){if(this._addRowCellValues){var row=null;if(this._addNew)row=this._addNew.get_row();var eventArgs=new $IG.CancelAddRowEventArgs(this,row,this._addRowCellValues);this._owner._raiseSenderClientEventStart(this,this._clientEvents["RowAdding"],eventArgs);if(!eventArgs.get_cancel()){this._get_owner()._actionList.add_transaction(new $IG.GridAction("AddRow","EditingCore",this._get_owner().get_behaviors().get_editingCore(),this._addRowCellValues));this._get_owner()._raiseClientEventEnd(eventArgs);this._addRowCellValues=null;}}},_sortRowIdPairs:function(a,b){return(b.index-a.index)},_cellValueChanged:function(args){var action=this._retrieveUpdateAction(args.cell.get_row());action._addUpdateCell(args.cell,args.oldValue);this._hasCellValueChanged=true;},_activeCellChanged:function(args){if(args.cell){var activeRow=args.cell.get_row();if(this._lastActiveRow&&(activeRow!=this._lastActiveRow&&this._hasCellValueChanged==true)){this._hasCellValueChanged=false;this._commitUpdates();}this._lastActiveRow=activeRow;}else this._lastActiveRow=null;},_actions:{},_retrieveUpdateAction:function(row){var rowIdPair=row.get_idPair();var actionKey=rowIdPair.key;if(actionKey.length==0)actionKey=rowIdPair.index;var action=this._actions[actionKey];if(!action||!action._object){action=new $IG.UpdateRowAction("UpdateRow",this.get_name(),row,new $IG.GridAffectedItems());this._actions[actionKey]=action;}this._owner._actionList.add_transaction(action);return action;},_onRowsDeleting:function(args){this._rowsToDelete.add(args.row);if(args.commit)this.commit();},_onRowAdding:function(args){this._addRowCellValues=args.cellValues;this.commit();},_initializeComplete:function(){this._activation=this._owner.get_behaviors().getBehaviorFromInterface($IG.IActivationBehavior);if(this._activation)this._activation._addActiveCellChangedEventHandler(Function.createDelegate(this,this._activeCellChanged));this._addNew=this._owner.get_behaviors().getBehaviorFromInterface($IG.IRowAddingBehavior);this._selection=this._owner.get_behaviors().getBehaviorFromInterface($IG.ISelectionBehavior);var deletionExemptRowIDs=this._get_clientOnlyValue("der");var shouldFireClientDeletedEvent=this._get_clientOnlyValue("fcde");if(shouldFireClientDeletedEvent&&this._clientEvents["RowsDeleted"]){var deletionExemptRows;if(deletionExemptRowIDs)deletionExemptRows=Sys.Serialization.JavaScriptSerializer.deserialize(deletionExemptRowIDs);else deletionExemptRows=new Array();var RowsDeletedEventArgs=new $IG.RowsDeletedEventArgs(this,deletionExemptRows);this._owner._raiseSenderClientEventStart(this,this._clientEvents["RowsDeleted"],RowsDeletedEventArgs);}var updatedRowIDs=this._get_clientOnlyValue("urp");if(updatedRowIDs&&this._clientEvents["RowUpdated"]){var updRows=Sys.Serialization.JavaScriptSerializer.deserialize(updatedRowIDs);for(var i=0;i<updRows.length;i++){var row=this._grid.get_rows().get_rowFromIDPair(updRows[i]);var rowUpdatedEventArgs=new $IG.RowUpdatedEventArgs(this,row);this._owner._raiseSenderClientEvent(this,this._clientEvents["RowUpdated"],rowUpdatedEventArgs);}}var shouldFireClientAddedEvent=this._get_clientOnlyValue("wri");if(shouldFireClientAddedEvent&&this._clientEvents["RowAdded"])this._owner._raiseSenderClientEvent(this,this._clientEvents["RowAdded"],null);},_responseComplete:function(callbackObject,responseOptions){if(responseOptions.updatedRowIdPair&&responseOptions.updatedRowValues){var row=this._grid.get_rows().get_rowFromIDPair(responseOptions.updatedRowIdPair);for(var key in responseOptions.updatedRowValues){var column=this._grid.get_columns().get_columnFromKey(key);if(!column.get_isTemplated()){var cell=row.get_cellByColumn(column);var updatePair=responseOptions.updatedRowValues[key];cell._set_value_internal(updatePair[0],updatePair[1]);}}if(this._clientEvents["RowUpdated"]){var rowUpdatedEventArgs=new $IG.RowUpdatedEventArgs(this,row);this._owner._raiseSenderClientEvent(this,this._clientEvents["RowUpdated"],rowUpdatedEventArgs);}}},_createBehaviorCollection:function(){return new $IG.EditingCoreBehaviorCollection(this._owner);},dispose:function(){if(this._grid){var util=this._grid._gridUtil;if(util){util._unregisterEventListener(this._grid,"CellValueChanged",this._cellValueChangedListener);this._cellValueChangedListener=null;util._unregisterEventListener(this._grid,"RowsDeleted",this._onRowsDeletingListener);this._onRowsDeletingListener=null;util._unregisterEventListener(this._grid,"RowAdded",this._onRowAddingListener);this._onRowAddingListener=null;}}$IG.EditingCore.callBaseMethod(this,"dispose");}};$IG.EditingCore.registerClass('Infragistics.Web.UI.EditingCore',$IG.GridBehaviorContainer,$IG.IEditingBehavior);$IG.EditingCoreBehaviorCollection=function(control){$IG.EditingCoreBehaviorCollection.initializeBase(this,[control]);};$IG.EditingCoreBehaviorCollection.prototype={_rowDeleting:null,get_rowDeleting:function(){return this._rowDeleting;},_rowAdding:null,get_rowAdding:function(){return this._rowAdding;},_cellEditing:null,get_cellEditing:function(){return this._cellEditing;},_rowEditingTemplate:null,get_rowEditingTemplate:function(){return this._rowEditingTemplate;},dispose:function(){this._rowDeleting=null;this._rowAdding=null;this._cellEditing=null;this._rowEditingTemplate=null;$IG.EditingCoreBehaviorCollection.callBaseMethod(this,"dispose");}};$IG.EditingCoreBehaviorCollection.registerClass('Infragistics.Web.UI.EditingCoreBehaviorCollection',$IG.BehaviorCollectionBase);$IG.UpdateRowAction=function(type,ownerName,object,value,tag){$IG.UpdateRowAction.initializeBase(this,[type,ownerName,object,value,tag]);};$IG.UpdateRowAction.prototype={get_value:function(){return this._value._items;},get_updatedCells:function(){return this._value;},_addUpdateCell:function(cell,oldValue){var colIdPair=cell.get_idPair().columnIDPair;var updatedCells=this.get_updatedCells();var updCellAction=null;for(var i=0;i<updatedCells.get_length();i++){var updCell=updatedCells.getItem(i);if(cell.get_grid()._gridUtil.areIdPairsEqual(colIdPair,updCell.colIdPair)){updCellAction=updCell;break;}}if(!updCellAction){updCellAction={"colIdPair":colIdPair,"oldValue":oldValue};updatedCells.add(updCellAction);}updCellAction.value=cell.get_value();updCellAction._commited=false;}};$IG.UpdateRowAction.registerClass('Infragistics.Web.UI.UpdateRowAction',$IG.GridAction);$IG.GridAffectedItems=function(){$IG.GridAffectedItems.initializeBase(this);this._lsize=0;this._items=new Array();};$IG.GridAffectedItems.prototype={add:function(item){if(item==null)return;this._lsize++;this._items[(this._lsize-1)]=item;},remove:function(index){if(index<0||index>this._items.length-1)return;this._items[index]=null;for(var i=index;i<=this._lsize;i++)this._items[i]=this._items[i+1];this._lsize--;},indexOf:function(item){for(var i=0;i<this._lsize;i++){if(item==this._items[i])return i;}return-1;},isEmpty:function(){return this._lsize==0;},get_length:function(){return this._lsize},getItem:function(index){return this._items[index];},clear:function(){for(var i=0;i<this._lsize;i++)this._items[i]=null;this._lsize=0;},clone:function(){var c=new GridAffectedItems();for(var i=0;i<this._lsize;i++)c.add(this._items[i]);return c;}};$IG.GridAffectedItems.registerClass('Infragistics.Web.UI.GridAffectedItems');$IG.CancelRowsDeletingEventArgs=function(deleting,rows){$IG.CancelRowsDeletingEventArgs.initializeBase(this,[deleting]);this._rows=rows;};$IG.CancelRowsDeletingEventArgs.prototype={get_rows:function(){return this._rows;}};$IG.CancelRowsDeletingEventArgs.registerClass('Infragistics.Web.UI.CancelRowsDeletingEventArgs',$IG.CancelBehaviorEventArgs);$IG.RowsDeletedEventArgs=function(deleting,deletionExemptRowIDs){$IG.RowsDeletedEventArgs.initializeBase(this,[deleting]);this._deletionExemptRowIDs=deletionExemptRowIDs;};$IG.RowsDeletedEventArgs.prototype={get_canceled_rowIDPairs:function(){return this._deletionExemptRowIDs;}};$IG.RowsDeletedEventArgs.registerClass('Infragistics.Web.UI.RowsDeletedEventArgs',$IG.EventArgs);$IG.CancelAddRowEventArgs=function(addNewRow,row,cellValues){$IG.CancelAddRowEventArgs.initializeBase(this,[addNewRow]);this._row=row;this._cellValues=cellValues;};$IG.CancelAddRowEventArgs.prototype={get_row:function(){return this._row;},get_cellValues:function(){return this._cellValues;}};$IG.CancelAddRowEventArgs.registerClass('Infragistics.Web.UI.CancelAddRowEventArgs',$IG.CancelBehaviorEventArgs);$IG.CancelUpdateRowEventArgs=function(updating,row){$IG.CancelUpdateRowEventArgs.initializeBase(this,[updating]);this._row=row;};$IG.CancelUpdateRowEventArgs.prototype={get_row:function(){return this._row;}};$IG.CancelUpdateRowEventArgs.registerClass('Infragistics.Web.UI.CancelUpdateRowEventArgs',$IG.CancelBehaviorEventArgs);$IG.RowUpdatedEventArgs=function(row){$IG.RowUpdatedEventArgs.initializeBase(this);this._row=row;};$IG.RowUpdatedEventArgs.prototype={get_row:function(){return this._row;}};$IG.RowUpdatedEventArgs.registerClass('Infragistics.Web.UI.RowUpdatedEventArgs',$IG.EventArgs); 
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();