📄 igf_grid_editing.js
字号:
{var activeCell=this._activation.get_activeCell();if(activeCell)
activeCell.get_element().focus();}}}else if(evnt!=null&&evnt.type=="blur"){if(this._grid.getEditMode()=="row"){this.exitEditMode(true);}else
this.exitEditMode();}
else
this.exitEditMode();}},__resolveEditor:function(cell)
{if(cell==null)
return null;var editor=null;var editorName="colEd"+cell.getIndex();editor=this.editors[editorName];if(editor==null){var columnEditor=document.getElementById(this._grid.getId()+":colEd"+cell.getIndex());if(columnEditor!=null){var readonly=columnEditor.getAttribute("readonly");if(readonly!=null&&readonly=="true")
return null;}
var editorDiv=document.getElementById(this._grid.getId()+":colEdDiv"+cell.getIndex());if(editorDiv!=null){editor=new $IG.GridInternalWrapperEditor(editorDiv);this.editors[editorName]=editor;}}
if(editor==null){editor=new $IG.GridInternalEditor(cell.elm);this.editors[editorName]=editor;}
if(editor._originalNotifyLostFocus==null)
{editor._originalNotifyLostFocus=editor.notifyLostFocus;editor.notifyLostFocus=Function.createDelegate(this,this.__editorLostFocus);}
if(editor._originalNotifyFocus==null)
{editor._originalNotifyFocus=editor.notifyFocus;editor.notifyFocus=Function.createDelegate(this,this.__editorFocus);}
return editor;},_createObjects:function(props)
{this._editModeActions=new $IG.EditModeActions("EditModeActions",null,[[props]],this);},_createCollections:function(collectionsManager)
{this._editors=collectionsManager.register_collection(0,$IG.ObjectCollection);var collectionItems=collectionsManager._collections[0];for(var columnKey in collectionItems)
this._editors._addObject($IG.ColumnEditor,null,columnKey);},_intializeComplete:function()
{this._activation=this._parentCollection.getBehaviorFromInterface($IG.IActivationBehavior);if(this._activation){this._activation.addActiveCellChangingEventHandler(Function.createDelegate(this,this._activeCellChanging));this._activation.addActiveCellChangedEventHandler(Function.createDelegate(this,this._activeCellChanged));}},dipose:function()
{}}
$IG.GridEditing.registerClass('Infragistics.Web.UI.GridEditing',$IG.GridBehavior,$IG.IEditingBehavior);$IG.GridEditingProps=new function()
{this.Count=$IG.GridBehaviorProps.Count;};$IG.EditMouseClickAction=function(){}
$IG.EditMouseClickAction.prototype={None:0,Single:1,Double:2};$IG.EditMouseClickAction.registerEnum("Infragistics.Web.UI.EditMouseClickAction");$IG.EditModeActionsProps=new function()
{this.MouseClick=[$IG.ObjectBaseProps.Count+0,$IG.EditMouseClickAction.Double];this.EnableF2=[$IG.ObjectBaseProps.Count+1,true];this.EnableOnActive=[$IG.ObjectBaseProps.Count+2,false];this.EnableOnKeyPress=[$IG.ObjectBaseProps.Count+3,true];this.Count=$IG.ObjectBaseProps.Count+4;};$IG.ColumnEditorProps=new function()
{this.ColumnKey=[$IG.ObjectBaseProps.Count+0,""];this.EditorID=[$IG.ObjectBaseProps.Count+1,""];this.ReadOnly=[$IG.ObjectBaseProps.Count+2,false];this.Count=$IG.ObjectBaseProps.Count+3;};$IG.EditModeActions=function(obj,element,props,control)
{var csm=obj?new $IG.ObjectClientStateManager(props[0]):null;$IG.EditModeActions.initializeBase(this,[obj,element,props,control,csm]);}
$IG.EditModeActions.prototype={get_mouseClick:function()
{return this._get_value($IG.EditModeActionsProps.MouseClick);},set_mouseClick:function(value)
{this._set_value($IG.EditModeActionsProps.MouseClick,value);},get_enableF2:function()
{return this._get_value($IG.EditModeActionsProps.EnableF2,true);},set_enableF2:function(value)
{this._set_value($IG.EditModeActionsProps.EnableF2,value);},get_enableOnActive:function()
{return this._get_value($IG.EditModeActionsProps.EnableOnActive,true);},set_enableOnActive:function(value)
{this._set_value($IG.EditModeActionsProps.EnableOnActive,value);},get_enableOnKeyPress:function()
{return this._get_value($IG.EditModeActionsProps.EnableOnKeyPress,true);},set_enableOnKeyPress:function(value)
{this._set_value($IG.EditModeActionsProps.EnableOnKeyPress,value);}}
$IG.EditModeActions.registerClass('Infragistics.Web.UI.EditModeActions',$IG.ObjectBase);$IG.GridInternalEditor=function(parentElement)
{var editorDiv=document.createElement("div");editorDiv.style.border="0px";editorDiv.style.padding="0px";editorDiv.style.margin="0px";this.input=new IgUIElement(document.createElement("input"));editorDiv.appendChild(this.input.elm);editorDiv.style.display="none";$IG.GridInternalEditor.initializeBase(this,[editorDiv]);this._inputOnBlurHandler=Function.createDelegate(this,this._onBlurHandler);this._inputOnFocusHandler=Function.createDelegate(this,this._onFocusHandler);$addHandler(this.input.elm,"keydown",Function.createDelegate(this,this._onKeyDownHandler));$addHandler(this.input.elm,"click",Function.createDelegate(this,this._onClickHandler));}
$IG.GridInternalEditor.prototype={get_value:function()
{return this.input.elm.value;},set_value:function(val)
{this.input.elm.value=val;},saveState:function()
{this.prevValue=this.get_value();},restoreState:function()
{this.set_value(this.prevValue);},showEditor:function(top,left,width,height,cssClass,parent)
{parent=new IgUIElement(parent);var leftPadding=parent.getPadding("left");if(leftPadding>0){this.setStyle("margin-left",""+(-leftPadding)+"px");}
var topPadding=parent.getPadding("top");if(topPadding>0){this.setStyle("margin-top",""+(-topPadding)+"px");}
this.input.setStyle("left","0px");this.input.setStyle("right","0px");if(ig.isIE){this.input.setStyle("margin-top","-1px");}
parent.setStyle("visibility","hidden");this.setStyle("visibility","visible");this.elm.style.display="";this.input.elm.className=cssClass;this.setSize(width,height);this.input.setSize(width,height);$addHandler(this.input.elm,"blur",this._inputOnBlurHandler);$addHandler(this.input.elm,"focus",this._inputOnFocusHandler);},enableEditor:function(){if(this.input.elm.select)
this.input.elm.select();this.input.elm.focus();},notifyFocus:function(evnt)
{},notifyLostFocus:function(evnt)
{},get_displayText:function(val)
{return this.input.elm.value;},hideEditor:function()
{$removeHandler(this.input.elm,"focus",this._inputOnFocusHandler);$removeHandler(this.input.elm,"blur",this._inputOnBlurHandler);var cell=ig.grid.getTargetCell(this.elm);if(!ig.isNull(cell)){cell.setStyle("visibility","visible");this.elm.style.display="none";this.elm.parentNode.removeChild(this.elm);}},_onKeyDownHandler:function(evnt)
{var key=evnt.keyCode;if(key==evnt.KEY_LEFT){evnt.event.cancelBubble=true;}else if(key==evnt.KEY_RIGHT){evnt.event.cancelBubble=true;}else if(key==evnt.KEY_ESCAPE){this.notifyLostFocus(evnt);}else if(key==evnt.KEY_TAB||key==evnt.KEY_RETURN)
this.notifyLostFocus(evnt);},_onClickHandler:function(evnt)
{$util.cancelEvent(evnt);this.notifyFocus(evnt);},_onFocusHandler:function(evnt)
{this.notifyFocus(evnt);evnt.stopPropagation();evnt.preventDefault();},_onBlurHandler:function(evnt)
{this.notifyLostFocus(evnt);},__setCursorPosition:function(pos){if(this.input.elm&&this.input.elm.createTextRange){var range=this.input.elm.createTextRange();range.collapse(true);range.moveEnd('character',pos);range.moveStart('character',pos);range.select();}else if(this.input.elm.selectionEnd){this.input.elm.selectionEnd=pos;this.input.elm.selectionStart=pos;}},__getCursorPosition:function(){var field=this.input.elm;var cursorPos=-1;if(document.selection&&document.selection.createRange){var range=document.selection.createRange().duplicate();if(range.parentElement()==field){range.moveStart('textedit',-1);cursorPos=range.text.length;}}else if(field.selectionEnd){cursorPos=field.selectionEnd;}
return cursorPos;}}
$IG.GridInternalEditor.registerClass('Infragistics.Web.UI.GridInternalEditor',IgUIElement);$IG.GridInternalWrapperEditor=function(editorDiv)
{this.input=ig.findDescendant(editorDiv,null,null,"input");if(this.input==null)
this.input=ig.findDescendant(editorDiv,null,null,"select");if(this.input==null)
this.input=ig.findDescendant(editorDiv,null,null,"textarea");if(this.input.type=="checkbox"){editorDiv.style.textAlign="center";}
this._inputOnBlurHandler=Function.createDelegate(this,this._onBlurHandler);this._inputOnFocusHandler=Function.createDelegate(this,this._onFocusHandler);$IG.GridInternalWrapperEditor.initializeBase(this,[editorDiv]);$addHandler(this.input,"keydown",Function.createDelegate(this,this._onKeyDownHandler));$addHandler(this.input,"click",Function.createDelegate(this,this._onClickHandler));}
$IG.GridInternalWrapperEditor.prototype={get_value:function()
{if(this.input.type=="checkbox"){return this.input.checked;}else if(this.input.type=="radio"){if(this.input.form){var radiobuttons=this.input.form[this.input.name];for(var i=radiobuttons.length-1;i>-1;i--){if(radiobuttons[i].checked){return radiobuttons[i].value;}}}}
else
return this.input.value;},set_value:function(val)
{if(this.input.type=="checkbox"){this.input.checked=(val==true||val=="true");}else if(this.input.type=="radio"){var radiobuttons=this.input.form[this.input.name];for(var i=radiobuttons.length-1;i>-1;i--){if(radiobuttons[i].value==val){radiobuttons[i].checked=true;}}}
else{this.input.value=val;}},saveState:function()
{this.prevValue=this.get_value();},restoreState:function()
{this.set_value(this.prevValue);},showEditor:function(top,left,width,height,cssClass,parent)
{parent=new IgUIElement(parent);var leftPadding=parent.getPadding("left");if(leftPadding>0){this.setStyle("margin-left",""+(-leftPadding)+"px");}
var topPadding=parent.getPadding("top");if(topPadding>0){this.setStyle("margin-top",""+(-topPadding)+"px");}
var input=new IgUIElement(this.input);if(this.input.type!="radio"){input.setStyle("left","0px");input.setStyle("right","0px");if(ig.isIE){input.setStyle("margin-top","-1px");}}
parent.setStyle("visibility","hidden");this.setStyle("visibility","visible");this.elm.style.display="";this.elm.className=cssClass;this.setSize(width,height);if(this.input.type=="text"||this.input.type=="textarea"){if(this.input.nextSibling==null&&this.input.nextSibling==null){input.setSize(width,height);$addHandler(this.input,"blur",this._inputOnBlurHandler);}else{input.setSize(null,height);}}else if(this.input.type=="select"){input.setSize(null,height);}
$addHandler(this.input,"focus",Function.createDelegate(this,this._onFocusHandler));},enableEditor:function(){if(this.input.select)
this.input.select();this.input.focus();},notifyFocus:function(evnt)
{},notifyLostFocus:function(evnt)
{},get_displayText:function(val)
{return val;},hideEditor:function()
{$removeHandler(this.input,"focus",this._inputOnFocusHandler);if(this.input.type=="text"||this.input.type=="textarea"){if(this.input.nextSibling==null&&this.input.nextSibling==null){$removeHandler(this.input,"blur",this._inputOnBlurHandler);}}
var cell=ig.grid.getTargetCell(this.elm);if(!ig.isNull(cell)){cell.setStyle("visibility","visible");this.elm.style.display="none";this.elm.parentNode.removeChild(this.elm);}},_onKeyDownHandler:function(evnt)
{var key=evnt.keyCode;if(key==evnt.KEY_LEFT||key==evnt.KEY_RIGHT||key==evnt.KEY_DOWN||key==evnt.KEY_UP){evnt.event.cancelBubble=true;}else if(key==evnt.KEY_ESCAPE){this.notifyLostFocus(evnt);}else if(key==evnt.KEY_TAB||(key==evnt.KEY_RETURN&&this.input.type!="textarea")){this.notifyLostFocus(evnt);}},_onClickHandler:function(evnt)
{if(this.input.type!="checkbox"&&this.input.type!="radio"){ig.ui.cancelClick=true;}
this.notifyFocus(evnt);},_onFocusHandler:function(evnt)
{this.notifyFocus(evnt);evnt.stopPropagation();evnt.preventDefault();},_onBlurHandler:function(evnt)
{this.notifyLostFocus(evnt);},__setCursorPosition:function(pos){if(this.input.type=="text"){var field=this.input;if(field!=null&&field.createTextRange){var range=field.createTextRange();range.collapse(true);range.moveEnd('character',pos);range.moveStart('character',pos);range.select();}else if(field.selectionEnd){field.selectionEnd=pos;field.selectionStart=pos;}}},__getCursorPosition:function(){if(this.input.type=="text"){var field=this.input;var cursorPos=-1;if(document.selection&&document.selection.createRange){var range=document.selection.createRange().duplicate();if(range.parentElement()==field){range.moveStart('textedit',-1);cursorPos=range.text.length;}}else if(field.selectionEnd){cursorPos=field.selectionEnd;}
return cursorPos;}else{return-1;}}}
$IG.GridInternalWrapperEditor.registerClass('Infragistics.Web.UI.GridInternalWrapperEditor',IgUIElement);$IG.ColumnEditor=function(adr,element,props,owner,csm)
{$IG.ColumnEditor.initializeBase(this,[adr,element,props,owner,csm]);}
$IG.ColumnEditor.prototype={get_columnKey:function()
{return this._get_value($IG.ColumnEditorProps.ColumnKey);},get_editorID:function()
{return this._get_value($IG.ColumnEditorProps.EditorID,true);},get_readOnly:function()
{return this._get_value($IG.ColumnEditorProps.ReadOnly,true);}}
$IG.ColumnEditor.registerClass('Infragistics.Web.UI.ColumnEditor',$IG.ObjectBase);$IG.CancelEditModeEventArgs=function(cell)
{$IG.CancelEditModeEventArgs.initializeBase(this);this._cell=cell;}
$IG.CancelEditModeEventArgs.prototype={getCell:function()
{return this._cell;}}
$IG.CancelEditModeEventArgs.registerClass('Infragistics.Web.UI.CancelEditModeEventArgs',$IG.CancelEventArgs);$IG.EditModeEventArgs=function(cell)
{$IG.EditModeEventArgs.initializeBase(this);this._cell=cell;}
$IG.EditModeEventArgs.prototype={getCell:function()
{return this._cell;}}
$IG.EditModeEventArgs.registerClass('Infragistics.Web.UI.EditModeEventArgs',$IG.EventArgs);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -