www-thermferm/jqwidgets/jqxgrid.edit.js

Sun, 07 Jul 2019 14:31:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Jul 2019 14:31:10 +0200
branch
stable
changeset 603
fcff55324b84
parent 511
2d1d43c3a2c2
child 617
b216f9d4b917
permissions
-rw-r--r--

Merged fix from default

117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
2 jQWidgets v4.5.2 (2017-May)
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
3 Copyright (c) 2011-2017 jQWidgets.
117
7119ea8a5225 Initial setup of wqwidgets
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 License: http://jqwidgets.com/license/
511
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
5 */
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
6 !function(a){a.extend(a.jqx._jqxGrid.prototype,{_handledblclick:function(b,c){if(null!=b.target&&!c.disabled&&!a(b.target).ischildof(this.columnsheader)){var d;if(b.which?d=3==b.which:b.button&&(d=2==b.button),!d){var e;if(b.which?e=2==b.which:b.button&&(e=1==b.button),!e){var f=this.showheader?this.columnsheader.height()+2:0,g=this._groupsheader()?this.groupsheader.height():0,h=this.showtoolbar?this.toolbarheight:0;g+=h;var i=this.host.offset(),j=b.pageX-i.left,k=b.pageY-f-i.top-g,l=this._hittestrow(j,k);if(l){var m=l.row,n=l.index,o=b.target.className,p=this.table[0].rows[n];if(null!=p){c.mousecaptured=!0,c.mousecaptureposition={left:b.pageX,top:b.pageY-g};for(var q=this.hScrollInstance,r=q.value,s=0,t=(this.groupable?this.groups.length:0,0);t<p.cells.length;t++){var u=parseInt(a(this.columnsrow[0].cells[t]).css("left")),v=u-r;c.columns.records[t].pinned&&(v=u);var w=this._getcolumnat(t);if(null==w||!w.hidden){var x=v+a(this.columnsrow[0].cells[t]).width();if(x>=j&&j>=v){s=t;break}}}if(null!=m){var w=this._getcolumnat(s);o.indexOf("jqx-grid-group-expand")==-1&&o.indexOf("jqx-grid-group-collapse")==-1&&m.boundindex!=-1&&c.begincelledit(c.getboundindex(m),w.datafield,w.defaulteditorvalue)}}}}}}},_getpreveditablecolumn:function(a){for(var b=this;a>0;){a--;var c=b.getcolumnat(a);if(!c)return null;if(c.editable&&!c.hidden)return c}return null},_getnexteditablecolumn:function(a){for(var b=this;a<this.columns.records.length;){a++;var c=b.getcolumnat(a);if(!c)return null;if(c.editable&&!c.hidden)return c}return null},_handleeditkeydown:function(b,c){if(c.handlekeyboardnavigation){var d=c.handlekeyboardnavigation(b);if(1==d)return!0}var e=b.charCode?b.charCode:b.keyCode?b.keyCode:0;if(c.editEvent=b,c.showfilterrow&&c.filterable&&this.filterrow&&a(b.target).ischildof(this.filterrow))return!0;if(b.target.className&&b.target.className.indexOf("jqx-grid-widget")>=0)return!0;if(c.pageable&&a(b.target).ischildof(this.pager))return!0;if(this.showtoolbar&&a(b.target).ischildof(this.toolbar))return!0;if(this.showeverpresentrow){if(this.addnewrowtop&&a(b.target).ischildof(this.addnewrowtop))return!0;if(this.addnewrowbottom&&a(b.target).ischildof(this.addnewrowbottom))return!0}if(this.showstatusbar&&a(b.target).ischildof(this.statusbar))return!0;if(this.rowdetails&&a(b.target).ischildof(this.content.find("[role='rowgroup']")))return!0;if(this.editcell){if("selectedrow"===this.editmode){if(13===e)return this.endrowedit(this.editcell.row,!1),!1;if(27===e)return this.endrowedit(this.editcell.row,!0),!1;if(32==e&&this._currentColumn&&"checkbox"==this.getcolumn(this._currentColumn).columntype){var f=this.getcolumn(this._currentColumn);if(f.editable){var g=!this.getcellvalue(this.editcell.row,f.datafield),h=this.getrowdata(this.editcell.row),i=this.editcell.row,h=c.getrowdata(c.editcell.row);this.setcellvalue(this.editcell.row,f.datafield,g,!1);var j=this._focusedColumn,k=this._currentColumn,l=this._currentEditableColumn;if(this.endrowedit(this.editcell.row,!1),this.beginrowedit(i,!1),this._currentColumn=k,this._focusedColumn=j,this._currentEditableColumn=l,this._renderrows(),this.selectcell(i,f.datafield),this._oldselectedcell=this.selectedcell,j){var m=this;setTimeout(function(){m.selectcell(i,f.datafield),m._oldselectedcell=m.selectedcell,a(m._checkboxCells[f.datafield].checkbox).jqxCheckBox("focus")},25)}return!1}}if(9===e){var n=this.editcell.datafield,o=this._getcolumnindex(n);this._currentEditableColumn?o=this._currentEditableColumn:this._currentEditableColumn=o;var f=this._getnexteditablecolumn(o);if(b.shiftKey&&(f=this._getpreveditablecolumn(o)),f){var o=this._getcolumnindex(f.datafield);if(this.editcell[f.datafield]){this._currentEditableColumn=o;var p=this.editcell[f.datafield].editor;p&&(p.data().jqxWidget&&p.data().jqxWidget.focus?p.data().jqxWidget.focus():p.focus()),this._focusedColumn=f.datafield,this._currentColumn=f.datafield}else if("checkbox"==f.columntype)return this._currentColumn=f.datafield,this._currentEditableColumn=o,this.selectcell(this.editcell.row,f.datafield),this._oldselectedcell=this.selectedcell,this._checkboxCells[f.datafield]&&a(this._checkboxCells[f.datafield].checkbox).jqxCheckBox("focus"),!1}return!1}return!0}if(null==this.editcell.columntype||"textbox"==this.editcell.columntype||"numberinput"==this.editcell.columntype||"combobox"==this.editcell.columntype||"datetimeinput"==this.editcell.columntype){if(e>=33&&e<=40&&"multiplecellsadvanced"==c.selectionmode){var p="textbox"==this.editcell.columntype||null==this.editcell.columntype?this.editcell.editor:this.editcell.editor.find("input"),q=c._selection(p),r=p.val().length;q.length>0&&"datetimeinput"!=this.editcell.columntype&&(c._cancelkeydown=!0),q.start>0&&37==e&&(c._cancelkeydown=!0),q.start<r&&39==e&&"datetimeinput"!=this.editcell.columntype&&(c._cancelkeydown=!0),"datetimeinput"==this.editcell.columntype&&39==e&&q.start+q.length<r&&(c._cancelkeydown=!0)}}else"dropdownlist"==this.editcell.columntype?(37==e||39==e&&"multiplecellsadvanced"==c.selectionmode)&&(c._cancelkeydown=!1):"multiplecellsadvanced"==this.selectionmode&&"textbox"!=this.editcell.columntype&&"numberinput"!=this.editcell.columntype&&(c._cancelkeydown=!0);if(32==e&&"checkbox"==c.editcell.columntype){var f=c.getcolumn(c.editcell.datafield);if(f.editable){var g=!c.getcellvalue(c.editcell.row,c.editcell.column);if(f.cellbeginedit){var s=f.cellbeginedit(c.editcell.row,f.datafield,f.columntype,!g);if(0==s)return!1}var h=c.getrowdata(c.editcell.row);return c.setcellvalue(c.editcell.row,c.editcell.column,g,!0),c._raiseEvent(18,{rowindex:c.editcell.row,row:h,datafield:c.editcell.column,oldvalue:!g,value:g,columntype:"checkbox"}),!1}}if(9==e){var t=this.editcell.row,n=this.editcell.column,u=n,o=c._getcolumnindex(n),v=!1,w=c.getrowvisibleindex(t);this.editchar="";var x=this.editcell.validated;if(!this.editcell.validated)var x=this.endcelledit(this.editcell.row,this.editcell.column,!1,!0,!1);if(0!=x){if(b.shiftKey){var f=c._getpreveditablecolumn(o);if(f)n=f.datafield,v=!0,c.selectionmode.indexOf("cell")!=-1&&(c.selectprevcell(t,u),c._oldselectedcell=c.selectedcell,setTimeout(function(){c.ensurecellvisible(w,n)},10));else{var y=c._getlastvisiblecolumn();v=!0,n=y.displayfield,t--,c.selectionmode.indexOf("cell")!=-1&&(c.clearselection(),c.selectcell(t,n),c._oldselectedcell=c.selectedcell,setTimeout(function(){c.ensurecellvisible(w,n)},10))}}else{var f=c._getnexteditablecolumn(o);if(f)n=f.datafield,v=!0,c.selectionmode.indexOf("cell")!=-1&&(c.selectnextcell(t,u),c._oldselectedcell=c.selectedcell,setTimeout(function(){c.ensurecellvisible(w,n)},10));else{var z=c._getfirstvisiblecolumn();v=!0,n=z.displayfield,t++,c.selectionmode.indexOf("cell")!=-1&&(c.clearselection(),c.selectcell(t,n),c._oldselectedcell=c.selectedcell,setTimeout(function(){c.ensurecellvisible(w,n)},10))}}if(!v)return null!=this.editcell&&(c.endcelledit(t,n,!1),this._renderrows(this.virtualsizeinfo)),!0;c.begincelledit(t,n),null!=this.editcell&&"checkbox"==this.editcell.columntype&&this._renderrows(this.virtualsizeinfo)}return!1}if(13==e){var A=this.selectedcell;if(A)var B=this.getrowvisibleindex(A.rowindex);if(this.endcelledit(this.editcell.row,this.editcell.column,!1,!0),"multiplecellsadvanced"==this.selectionmode){var C=c.getselectedcell();if(null!=C&&c.selectcell&&null==this.editcell&&C.rowindex+1<this.dataview.totalrecords)if(this.sortcolumn!=C.datafield){var w=this.getrowvisibleindex(C.rowindex),D=this.dataview.loadedrecords[w+1];if(D&&(!this.pageable||this.pageable&&w+1<(this.dataview.pagenum+1)*this.pagesize)){this.clearselection(!1),this.selectcell(this.getboundindex(D),C.datafield);var C=this.getselectedcell();this.ensurecellvisible(D.visibleindex,C.datafield)}}else if(null!=A){var E=this.dataview.loadedrecords[B+1];if(E)if(!this.pageable||this.pageable&&B+1<this.pagesize)this.clearselection(!1),this.selectcell(this.getboundindex(E),C.datafield);else if(this.pageable&&B+1>=this.pagesize){this.clearselection(!1);var E=this.dataview.loadedrecords[B];this.selectcell(this.getboundindex(E),C.datafield)}}}return!1}if(27==e)return this.endcelledit(this.editcell.row,this.editcell.column,!0,!0),!1}else{var F=!1;if(113==e&&(F=!0),!b.ctrlKey&&!b.altKey&&!b.metaKey){if(e>=48&&e<=57&&(this.editchar=String.fromCharCode(e),F=!0),189===e&&(F=!0),e>=65&&e<=90){this.editchar=String.fromCharCode(e);var G=!1;b.shiftKey?G=b.shiftKey:b.modifiers&&(G=!!(4&b.modifiers)),G||(this.editchar=this.editchar.toLowerCase()),F=!0}else e>=96&&e<=105&&(this.editchar=e-96,this.editchar=this.editchar.toString(),F=!0);var H=a(".jqx-grid").length;F=F&&(1==H||H>1&&c.focused);var I=a.data(document.body,"jqxgrid.edit");if(void 0!==I&&""!==I&&(13===e||F)&&I!=c.element.id)return!0}if((13==e||F)&&c.getselectedrowindex){var t=c.getselectedrowindex();if("selectedrow"===c.editmode)return c.beginrowedit(t),!1;switch(c.selectionmode){case"singlerow":case"multiplerows":case"multiplerowsextended":if(t>=0){for(var n="",J=0;J<c.columns.records.length;J++){var f=c.getcolumnat(J);if(f.editable){n=f.datafield;break}}"selectedrow"===c.editmode?c.beginrowedit(t):c.begincelledit(t,n)}break;case"singlecell":case"multiplecells":case"multiplecellsextended":var C=c.getselectedcell();if(null!=C){var f=c._getcolumnbydatafield(C.datafield);"checkbox"!=f.columntype&&c.begincelledit(C.rowindex,C.datafield)}break;case"multiplecellsadvanced":var C=c.getselectedcell();if(null!=C)if(13==e){if(c.selectcell){var w=this.getrowvisibleindex(C.rowindex);if(w+1<c.dataview.totalrecords){var D=this.dataview.loadedrecords[w+1];if(D){this.clearselection(!1),this.selectcell(this.getboundindex(D),C.datafield);var C=this.getselectedcell();this.ensurecellvisible(D.visibleindex,C.datafield)}}}}else"selectedrow"!==c.editmode&&c.begincelledit(C.rowindex,C.datafield)}return!1}if(46==e){var K=c.getselectedcells();if(c.selectionmode.indexOf("cell")==-1&&c._getcellsforcopypaste&&(K=c._getcellsforcopypaste()),null!=K&&K.length>0){for(var L=0;L<K.length;L++){var C=K[L];if(C.datafield){var f=c.getcolumn(C.datafield),M=c.getcellvalue(C.rowindex,C.datafield);if(""!==M&&f.editable&&c.enablekeyboarddelete){var N=null;if("checkbox"==f.columntype&&(f.threestatecheckbox||(N=!1)),f.cellbeginedit){var s=f.cellbeginedit(C.rowindex,f.datafield,f.columntype,N);if(0==s)return!1}var h=c.getrowdata(C.rowindex);if(c._raiseEvent(17,{rowindex:C.rowindex,row:h,datafield:C.datafield,value:M}),L==K.length-1?(c.setcellvalue(C.rowindex,C.datafield,N,!0),f.displayfield!=f.datafield&&c.setcellvalue(C.rowindex,f.displayfield,N,!0)):(c.setcellvalue(C.rowindex,C.datafield,N,!1),f.displayfield!=f.datafield&&c.setcellvalue(C.rowindex,f.displayfield,N,!0)),f.cellendedit){f.cellendedit(C.rowindex,f.datafield,f.columntype,N)}c._raiseEvent(18,{rowindex:C.rowindex,row:h,datafield:C.datafield,oldvalue:M,value:N})}}}return this.dataview.updateview(),this._renderrows(this.virtualsizeinfo),!1}}if(32==e){var C=c.getselectedcell();if(null!=C){var f=c.getcolumn(C.datafield);if("checkbox"==f.columntype&&f.editable){var g=!c.getcellvalue(C.rowindex,C.datafield);if(f.cellbeginedit){var s=f.cellbeginedit(C.rowindex,f.datafield,f.columntype,!g);if(0==s)return!1}var h=c.getrowdata(C.rowindex);return c._raiseEvent(17,{rowindex:C.rowindex,row:h,datafield:C.datafield,value:!g,columntype:"checkbox"}),c.setcellvalue(C.rowindex,C.datafield,g,!0),c._raiseEvent(18,{rowindex:C.rowindex,row:h,datafield:C.datafield,oldvalue:!g,value:g,columntype:"checkbox"}),!1}}}}return!0},begincelledit:function(b,c,d,e,f){var g=this.getcolumn(c);if(this._cellscache=new Array,null!=c&&"number"!=g.columntype&&"button"!=g.columntype&&!g.createwidget){if(this.groupable){if(this.groups.indexOf(c)>=0)return;if(this.groups.indexOf(g.displayfield)>=0)return}if(void 0==this.editrow){if(this.editcell){if(this.editcell.row==b&&this.editcell.column==c)return!0;if("selectedrow"===this.editmode&&this.editcell.row==b)return;var h=this.endcelledit(this.editcell.row,this.editcell.column,!1,!0,!1);if(0==h)return}var i="checkbox"==g.columntype||"button"==g.columntype||g.createwidget;if(this.host.removeClass("jqx-disableselect"),this.content.removeClass("jqx-disableselect"),g.editable){if(g.cellbeginedit){var j=this.getcell(b,c),k=g.cellbeginedit(b,c,g.columntype,null!=j?j.value:null);if(0==k)return}var l=this.getrowvisibleindex(b);if(this.editcell=this.getcell(b,c),this.editcell&&(this.editcell.visiblerowindex=l,!this.editcell.editing)){if(i||(this.editcell.editing=!0),this.editcell.columntype=g.columntype,this.editcell.defaultvalue=d,void 0!=g.defaultvalue&&(this.editcell.defaultvalue=g.defaultvalue),this.editcell.init=!0,"checkbox"!=g.columntype&&"selectedrow"!=this.editmode){var m=this.getrowdata(b);this._raiseEvent(17,{rowindex:b,row:m,datafield:g.datafield,value:this.editcell.value,columntype:g.columntype})}if(a.data(document.body,"jqxgrid.edit",this.element.id),!i){var n=this.getrowvisibleindex(b);e!==!1&&(this.autorowheight||this.ensurecellvisible(n,g.datafield)),f!==!1&&this._renderrows(this.virtualsizeinfo)}if(this.editcell)return this.editcell.init=!1,!0}}else{if(!this.editcell)return;this.editcell.editor=null,this.editcell.editing=!1,f!==!1&&this._renderrows(this.virtualsizeinfo),this.editcell=null}}}},getScrollTop:function(){if(this._py)return pageYOffset;if(this._py="undefined"!=typeof pageYOffset,this._py)return pageYOffset;var a=document.body,b=document.documentElement;return b=b.clientHeight?b:a,b.scrollTop},getScrollLeft:function(){if("undefined"!=typeof pageXOffset)return pageXOffset;var a=document.body,b=document.documentElement;return b=b.clientHeight?b:a,b.scrollLeft},endcelledit:function(b,c,d,e,f){if(void 0!=b&&void 0!=c||(this.editcell&&(b=this.editcell.row,c=this.editcell.column),void 0==d&&(d=!0)),this.editcell){var g=this.getcolumn(c),h=this;if("selectedrow"===h.editmode)return void this.endrowedit(b,d);var i=function(){if(0!=f){if(h.isTouchDevice())return;if(!h.isNestedGrid){var a=h.getScrollTop(),b=h.getScrollLeft();try{h.element.focus(),h.content.focus(),a!=h.getScrollTop()&&window.scrollTo(b,a),setTimeout(function(){h.element.focus(),h.content.focus(),a!=h.getScrollTop()&&window.scrollTo(b,a)},10)}catch(a){}}}};if("checkbox"==g.columntype||"button"==g.columntype||g.createwidget)return this.editcell&&(this.editcell.editor=null,this.editcell.editing=!1,this.editcell=null),!0;var j=this._geteditorvalue(g),k=function(a){if(a._hidecelleditor(),g.cellendedit&&g.cellendedit(b,c,g.columntype,a.editcell.value,j),a.editchar=null,g.displayfield!=g.datafield){var d=a.getcellvalue(a.editcell.row,g.displayfield),f=a.editcell.value;oldvalue={value:f,label:d}}else oldvalue=a.editcell.value;var h=a.getrowdata(b);a._raiseEvent(18,{rowindex:b,row:h,datafield:c,displayfield:g.displayfield,oldvalue:j,value:j,columntype:g.columntype}),a.editcell.editor=null,a.editcell.editing=!1,a.editcell=null,(e||void 0==e)&&a._renderrows(a.virtualsizeinfo),i(),a.enablebrowserselection||(a.host.addClass("jqx-disableselect"),a.content.addClass("jqx-disableselect"))};if(d)return k(this),!1;if(this.validationpopup&&(this.validationpopup.hide(),this.validationpopuparrow.hide()),g.cellvaluechanging){var l=g.cellvaluechanging(b,c,g.columntype,this.editcell.value,j);void 0!=l&&(j=l)}if(g.validation){var m=this.getcell(b,c);try{var n=g.validation(m,j),o=this.gridlocalization.validationstring;void 0!=n.message&&(o=n.message);var p="boolean"==typeof n?n:n.result;if(!p)return void 0!=n.showmessage&&1!=n.showmessage||this._showvalidationpopup(b,c,o),this.editcell.validated=!1,!1}catch(a){return this._showvalidationpopup(b,c,this.gridlocalization.validationstring),this.editcell.validated=!1,!1}}if(g.displayfield!=g.datafield){var q=this.getcellvalue(this.editcell.row,g.displayfield),r=this.editcell.value;oldvalue={value:r,label:q}}else oldvalue=this.editcell.value;var s=this.getrowdata(b);if(g.cellendedit){var t=g.cellendedit(b,c,g.columntype,this.editcell.value,j);if(0==t)return this._raiseEvent(18,{rowindex:b,row:s,datafield:c,displayfield:g.displayfield,oldvalue:oldvalue,value:oldvalue,columntype:g.columntype}),k(this),!1}return this._raiseEvent(18,{rowindex:b,row:s,datafield:c,displayfield:g.displayfield,oldvalue:oldvalue,value:j,columntype:g.columntype}),this._hidecelleditor(!1),void 0!=this.editcell&&(this.editcell.editor=null,this.editcell.editing=!1),this.editcell=null,this.editchar=null,this.setcellvalue(b,c,j,e),this.enablebrowserselection||(this.host.addClass("jqx-disableselect"),this.content.addClass("jqx-disableselect")),a.jqx.browser.msie||i(),a.data(document.body,"jqxgrid.edit",""),!0}},beginrowedit:function(b){var c=this;c._oldselectedrow=b,this._cellscache=new Array;var d=!1;if("selectedrow"!=this.editmode&&(d=!0),d){var e=this.editmode;this.editmode="selectedrow"}var f=null;a.each(this.columns.records,function(a,d){if(c.editable&&this.editable){if("checkbox"===this.columntype||"custom"===this.columntype||"widget"===this.columntype||"template"===this.columntype||"button"===this.columntype)return!0;f||(f=this.datafield);var e=c.getcell(b,this.datafield);c.begincelledit(b,this.datafield,null,!1,!1);var g=c.getrowdata(b);c._raiseEvent(17,{rowindex:b,row:g,datafield:this.datafield,value:e.value,columntype:this.columntype})}}),c.editcell&&(c.editcell.init=!0),this._renderrows(this.virtualsizeinfo),d&&(this.editmode=e),f&&c.editcell&&setTimeout(function(){if(c.editcell){var a=c.editcell[f].editor;a&&(a.data().jqxWidget&&a.data().jqxWidget.focus?a.data().jqxWidget.focus():a.focus())}},25)},endrowedit:function(b,c){var d=this;if(this._currentEditableColumn=0,this._focusedColumn=null,this._currentColumn=null,this._checkboxCells=[],!this.editcell)return!1;if(void 0==this.editcell.editor&&"checkbox"!==this.editcell.columntype)return!1;var e=!1;if("selectedrow"!=this.editmode&&(e=!0),e){var f=this.editmode;this.editmode="selectedrow"}var g=!1,h={};this.validationpopup&&(this.validationpopup.hide(),this.validationpopuparrow.hide());for(var i=0;i<this.columns.records.length;i++){var j=this.columns.records[i];if(j.editable&&!j.hidden&&"checkbox"!=j.columntype&&!j.createwidget){var k=this._geteditorvalue(j),l=function(a){a._hidecelleditor();var c=a.getcellvalue(a.editcell.row,j.displayfield);if(j.cellendedit&&j.cellendedit(b,o,j.columntype,c,k),a.editchar=null,j.displayfield!=j.datafield){var d=a.getcellvalue(a.editcell.row,j.displayfield),e=c;m={value:e,label:d}}else m=c;var f=a.getrowdata(b);a._raiseEvent(18,{rowindex:b,row:f,datafield:o,displayfield:j.displayfield,oldvalue:c,value:c,columntype:j.columntype}),a.editcell.editing=!1};if(c)l(this);else{if(j.cellvaluechanging){var m=this.getcellvalue(this.editcell.row,j.displayfield),n=j.cellvaluechanging(b,o,j.columntype,m,k);void 0!=n&&(k=n)}var o=j.datafield;if(j.validation){var p=this.getcell(b,j.datafield);try{var q=j.validation(p,k),r=this.gridlocalization.validationstring;void 0!=q.message&&(r=q.message);var s="boolean"==typeof q?q:q.result;if(!s){void 0!=q.showmessage&&1!=q.showmessage||this._showvalidationpopup(b,o,r),g=!0,this.editcell[j.datafield].validated=!1;continue}}catch(a){this._showvalidationpopup(b,o,this.gridlocalization.validationstring),this.editcell[j.datafield].validated=!1,g=!0;continue}}if(j.displayfield!=j.datafield){var t=this.getcellvalue(this.editcell.row,j.displayfield),u=this.editcell.value;m={value:u,label:t}}else m=this.getcellvalue(this.editcell.row,j.displayfield);h[j.datafield]={newvalue:k,oldvalue:m}}}}var v={},w={};if(!g){this._hidecelleditor(!1);for(var i=0;i<this.columns.records.length;i++){var j=this.columns.records[i],o=j.datafield;if(!j.hidden&&j.editable){var x=this.getrowdata(b);if(!j.createwidget)if("checkbox"!=j.columntype){if(h[j.datafield]){var k=h[j.datafield].newvalue,m=h[j.datafield].oldvalue;if(j.cellendedit){var y=j.cellendedit(b,o,j.columntype,m,k);if(0==y){this._raiseEvent(18,{rowindex:b,row:x,datafield:o,displayfield:j.displayfield,oldvalue:m,value:m,columntype:j.columntype}),l(this);continue}}this.source.updaterow||this._raiseEvent(18,{rowindex:b,row:x,datafield:j.datafield,displayfield:j.displayfield,oldvalue:m,value:k,columntype:j.columntype}),v[j.datafield]=k,w[j.datafield]=m}}else{var k=this.getcellvalue(b,j.displayfield);this._raiseEvent(18,{rowindex:b,row:x,datafield:j.datafield,displayfield:j.displayfield,oldvalue:k,value:k,columntype:j.columntype})}}}var z=this.getrowid(b),x=this.getrowdata(b);if(a.each(v,function(a,b){if(b&&void 0!=b.label){var c=d.getcolumn(a);x[c.displayfield]=b.label,x[c.datafield]=b.value}else x[a]=b}),this.enablebrowserselection||(this.host.addClass("jqx-disableselect"),this.content.addClass("jqx-disableselect")),a.data(document.body,"jqxgrid.edit",""),this.editcell=null,this.editchar=null,this.source.updaterow&&!c){var A=!1,d=this,s=function(c){var e=d.source.updaterow;d.source.updaterow=null,0==c?(a.each(w,function(a,b){if(b&&void 0!=b.label){var c=d.getcolumn(a);x[c.displayfield]=b.label,x[c.datafield]=b.value}else x[a]=b}),d.updaterow(z,x)):d.updaterow(z,x);for(var f=0;f<d.columns.records.length;f++){var g=d.columns.records[f];g.datafield;d._raiseEvent(18,{rowindex:b,datafield:g.datafield,row:x,displayfield:g.displayfield,oldvalue:w[g.datafield],value:x[g.displayfield],columntype:g.columntype})}d.source.updaterow=e};try{A=this.source.updaterow(z,x,s),void 0==A&&(A=!0)}catch(a){return void(A=!1)}}else c||this.updaterow(z,x),this._renderrows(this.virtualsizeinfo)}return e&&(this.editmode=f),g},_selection:function(a){if("selectionStart"in a[0]){var b=a[0],c=b.selectionEnd-b.selectionStart;return{start:b.selectionStart,end:b.selectionEnd,length:c,text:b.value}}var d=document.selection.createRange();if(null==d)return{start:0,end:b.value.length,length:0};var e=a[0].createTextRange(),f=e.duplicate();e.moveToBookmark(d.getBookmark()),f.setEndPoint("EndToStart",e);var c=d.text.length;return{start:f.text.length,end:f.text.length+d.text.length,length:c,text:d.text}},_setSelection:function(a,b,c){if("selectionStart"in c[0])c[0].focus(),c[0].setSelectionRange(a,b);else{var d=c[0].createTextRange();d.collapse(!0),d.moveEnd("character",b),d.moveStart("character",a),d.select()}},findRecordIndex:function(a,b,c){var c=c;if(b)for(var d=c.length,e=0;e<d;e++){var f=c[e],g=f.label;if(a==g)return e}return-1},_destroyeditors:function(){var b=this;this.columns.records&&(a.each(this.columns.records,function(c,d){var e=a.trim(this.datafield).split(" ").join("");switch(this.columntype){case"dropdownlist":var f=b.editors["dropdownlist_"+e];f&&(f.jqxDropDownList("destroy"),b.editors["dropdownlist_"+e]=null);break;case"combobox":var g=b.editors["combobox_"+e];g&&(g.jqxComboBox("destroy"),b.editors["combobox_"+e]=null);break;case"datetimeinput":var h=b.editors["datetimeinput_"+this.datafield];h&&(h.jqxDateTimeInput("destroy"),b.editors["datetimeinput_"+e]=null);break;case"numberinput":var i=b.editors["numberinput_"+e];i&&(i.jqxNumberInput("destroy"),b.editors["numberinput_"+e]=null);break;case"custom":case"template":if(b.destroyeditor&&b.editors["templateeditor_"+e]&&(b.destroyeditor(b.editors["templateeditor_"+e]),b.editors["templateeditor_"+e]=null),b.destroyeditor)for(var j=b.getrows.length(),k=0;k<j;k++)b.editors["customeditor_"+e+"_"+k]&&(b.destroyeditor(b.editors["customeditor_"+e+"_"+k],k),b.editors["customeditor_"+e+"_"+k]=null);break;case"textbox":default:var l=b.editors["textboxeditor_"+e];l&&(b.removeHandler(l,"keydown"),b.editors["textbox_"+e]=null)}}),b.editors=new Array)},_showcelleditor:function(b,c,d,e,f){if(void 0!=d&&null!=this.editcell){if("checkbox"==c.columntype&&c.editable)return void("selectedrow"==this.editmode&&(this._checkboxCells||(this._checkboxCells=[]),this._checkboxCells[c.datafield]=d));void 0==f&&(f=!0),"selectedrow"==this.editmode&&(this.editchar="",f=!1);var g=c.datafield,h=a(d),i=this,j=this.editcell.editor,k=this.getcellvalue(b,g),l=this.getcelltext(b,g),m=this.hScrollInstance,n=m.value,o=parseInt(n);this.columns.records.indexOf(c);if(this.editcell.element=d,0==this.editcell.validated){var p="";this.validationpopup&&(p=this.validationpopup.text()),this._showvalidationpopup(b,g,p)}var q=function(a){i.hScrollInstance.isScrolling()||i.vScrollInstance.isScrolling()||f&&(i.isTouchDevice()||(a&&a.focus(),0!=i.gridcontent[0].scrollTop&&(i.scrolltop(Math.abs(i.gridcontent[0].scrollTop)),i.gridcontent[0].scrollTop=0),0!=i.gridcontent[0].scrollLeft&&(i.gridcontent[0].scrollLeft=0)))};switch(c.columntype){case"dropdownlist":if(this.host.jqxDropDownList){d.innerHTML="";var r=a.trim(c.datafield).split(" ").join(""),s=a.trim(c.displayfield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".","")),s.indexOf(".")!=-1&&(s=s.replace(".",""));var t=this.editors["dropdownlist_"+r];if(j=void 0==t?a("<div style='border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='dropdownlisteditor'></div>"):t,j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==t){j.prependTo(this.table),j[0].id="dropdownlisteditor"+this.element.id+r;var u=!!this.source._source,v=null;if(u){var w={localdata:this.source.records,datatype:this.source.datatype,async:!1};v=new a.jqx.dataAdapter(w,{autoBind:!1,async:!1,uniqueDataFields:[s],autoSort:!0,autoSortField:s})}else v=new a.jqx.dataAdapter(this.source,{autoBind:!1,uniqueDataFields:[s],async:!1,autoSort:!0,autoSortField:s});var x=!c.createeditor;j.jqxDropDownList({enableBrowserBoundsDetection:!0,keyboardSelection:!1,source:v,rtl:this.rtl,autoDropDownHeight:x,theme:this.theme,width:h.width()-2,height:h.height()-2,displayMember:s,valueMember:g}),this.editors["dropdownlist_"+r]=j,c.createeditor&&c.createeditor(b,k,j)}c._requirewidthupdate&&j.jqxDropDownList({width:h.width()-2});var y=j.jqxDropDownList("listBox").visibleItems;c.createeditor||(y.length<8?j.jqxDropDownList("autoDropDownHeight",!0):j.jqxDropDownList("autoDropDownHeight",!1));var k=this.getcellvalue(b,s),z=this.findRecordIndex(k,s,y);if(e&&(""!=k?j.jqxDropDownList("selectIndex",z,!0):j.jqxDropDownList("selectIndex",-1)),!this.editcell)return;void 0!=this.editcell.defaultvalue&&j.jqxDropDownList("selectIndex",this.editcell.defaultvalue,!0),f&&j.jqxDropDownList("focus")}break;case"combobox":if(this.host.jqxComboBox){d.innerHTML="";var r=a.trim(c.datafield).split(" ").join(""),s=a.trim(c.displayfield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".","")),s.indexOf(".")!=-1&&(s=s.replace(".",""));var A=this.editors["combobox_"+r];if(j=void 0==A?a("<div style='border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='comboboxeditor'></div>"):A,j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==A){j.prependTo(this.table),j[0].id="comboboxeditor"+this.element.id+r;var u=!!this.source._source,v=null;if(u){var w={localdata:this.source.records,datatype:this.source.datatype,async:!1};v=new a.jqx.dataAdapter(w,{autoBind:!1,async:!1,uniqueDataFields:[s],autoSort:!0,autoSortField:s})}else v=new a.jqx.dataAdapter(this.source,{autoBind:!1,uniqueDataFields:[s],async:!1,autoSort:!0,autoSortField:s});var x=!c.createeditor;j.jqxComboBox({enableBrowserBoundsDetection:!0,keyboardSelection:!1,source:v,rtl:this.rtl,autoDropDownHeight:x,theme:this.theme,width:h.width()-2,height:h.height()-2,displayMember:s,valueMember:g}),j.removeAttr("tabindex"),j.find("div").removeAttr("tabindex"),this.editors["combobox_"+r]=j,c.createeditor&&c.createeditor(b,k,j)}c._requirewidthupdate&&j.jqxComboBox({width:h.width()-2});var y=j.jqxComboBox("listBox").visibleItems;c.createeditor||(y.length<8?j.jqxComboBox("autoDropDownHeight",!0):j.jqxComboBox("autoDropDownHeight",!1));var k=this.getcellvalue(b,s),z=this.findRecordIndex(k,s,y);if(e&&(""!=k?(j.jqxComboBox("selectIndex",z,!0),j.jqxComboBox("val",k)):(j.jqxComboBox("selectIndex",-1),j.jqxComboBox("val",k))),!this.editcell)return;void 0!=this.editcell.defaultvalue&&j.jqxComboBox("selectIndex",this.editcell.defaultvalue,!0),this.editchar&&this.editchar.length>0&&j.jqxComboBox("input").val(this.editchar),f&&setTimeout(function(){if(q(j.jqxComboBox("input")),j)if(j.jqxComboBox("_setSelection",0,0),i.editchar)j.jqxComboBox("_setSelection",1,1),i.editchar=null;else if(j.jqxComboBox("input")){var a=j.jqxComboBox("input").val();j.jqxComboBox("_setSelection",0,a.length)}},10)}break;case"datetimeinput":if(this.host.jqxDateTimeInput){d.innerHTML="";var r=a.trim(c.datafield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".",""));var B=this.editors["datetimeinput_"+r];if(j=void 0==B?a("<div style='border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='datetimeeditor'></div>"):B,j.show(),j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==B){j.prependTo(this.table),j[0].id="datetimeeditor"+this.element.id+r;var C={calendar:this.gridlocalization};j.jqxDateTimeInput({firstDayOfWeek:this.gridlocalization.firstDay,enableBrowserBoundsDetection:!0,localization:C,_editor:!0,theme:this.theme,rtl:this.rtl,width:h.width(),height:h.height(),formatString:c.cellsformat}),this.editors["datetimeinput_"+r]=j,c.createeditor&&c.createeditor(b,k,j)}if(c._requirewidthupdate&&j.jqxDateTimeInput({width:h.width()-2}),e){if(""!=k&&null!=k){var D=new Date(k);"Invalid Date"==D&&this.source.getvaluebytype&&(D=this.source.getvaluebytype(k,{name:c.datafield,type:"date"})),j.jqxDateTimeInput("setDate",D)}else j.jqxDateTimeInput("setDate",null);void 0!=this.editcell.defaultvalue&&j.jqxDateTimeInput("setDate",this.editcell.defaultvalue)}if(f){var E=this.editEvent;setTimeout(function(){q(j.jqxDateTimeInput("dateTimeInput")),setTimeout(function(){if(j.jqxDateTimeInput("_selectGroup",0),i.editchar&&i.editchar.length>0){var a=parseInt(i.editchar);if(!isNaN(a)&&E){var b=E.charCode?E.charCode:E.keyCode?E.keyCode:0;j.jqxDateTimeInput("_handleKeyPress",E,b)}}},25)},10)}}break;case"numberinput":if(this.host.jqxNumberInput){d.innerHTML="";var r=a.trim(c.datafield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".",""));var F=this.editors["numberinput_"+r];if(j=void 0==F?a("<div style='border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='numbereditor'></div>"):F,j.show(),j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==F){j.prependTo(this.table),j[0].id="numbereditor"+this.element.id+r;var G="",H="left",I=2;c.cellsformat?c.cellsformat.indexOf("c")!=-1?(G=this.gridlocalization.currencysymbol,H=this.gridlocalization.currencysymbolposition,H="before"==H?"left":"right",c.cellsformat.length>1&&(I=parseInt(c.cellsformat.substring(1),10))):c.cellsformat.indexOf("p")!=-1&&(G=this.gridlocalization.percentsymbol,H="right",c.cellsformat.length>1&&(I=parseInt(c.cellsformat.substring(1),10))):I=0,j.jqxNumberInput({decimalSeparator:this.gridlocalization.decimalseparator,decimalDigits:I,inputMode:"simple",theme:this.theme,rtl:this.rtl,width:h.width()-1,height:h.height()-1,spinButtons:!0,symbol:G,symbolPosition:H}),this.editors["numberinput_"+r]=j,c.createeditor&&c.createeditor(b,k,j)}if(c._requirewidthupdate&&j.jqxNumberInput({width:h.width()-2}),e){if(""!=k&&null!=k){var J=k;j.jqxNumberInput("setDecimal",J)}else j.jqxNumberInput("setDecimal",0);if(void 0!=this.editcell.defaultvalue&&j.jqxNumberInput("setDecimal",this.editcell.defaultvalue),this.editchar&&this.editchar.length>0){var K=parseInt(this.editchar);isNaN(K)||j.jqxNumberInput("setDecimal",K)}f&&setTimeout(function(){
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
7 if(q(j.jqxNumberInput("numberInput")),j.jqxNumberInput("_setSelectionStart",0),i.editchar)c.cellsformat.length>0?j.jqxNumberInput("_setSelectionStart",2):j.jqxNumberInput("_setSelectionStart",1),i.editchar=null;else{var a=j.jqxNumberInput("spinButtons");if(a){var b=j.jqxNumberInput("numberInput").val();i._setSelection(j.jqxNumberInput("numberInput")[0],b.length,b.length)}else{var b=j.jqxNumberInput("numberInput").val();i._setSelection(j.jqxNumberInput("numberInput")[0],0,b.length)}j.jqxNumberInput("selectAll")}},10)}}break;case"custom":d.innerHTML="";var r=a.trim(c.datafield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".",""));var L=this.editors["customeditor_"+r+"_"+b];if(j=void 0==L?a("<div style='overflow: hidden; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='customeditor'></div>"):L,j.show(),j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==L){j.prependTo(this.table),j[0].id="customeditor"+this.element.id+r+"_"+b,this.editors["customeditor_"+r+"_"+b]=j;var M=h.width()-1,N=h.height()-1;j.width(M),j.height(N),c.createeditor&&c.createeditor(b,k,j,l,M,N,this.editchar)}c._requirewidthupdate&&j.width(h.width()-2);break;case"template":d.innerHTML="";var r=a.trim(c.datafield).split(" ").join("");r.indexOf(".")!=-1&&(r=r.replace(".",""));var O=this.editors["templateeditor_"+r];if(j=void 0==O?a("<div style='overflow: hidden; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='templateeditor'></div>"):O,j.show(),j.css("top",a(d).parent().position().top),this.oldhscroll?j.css("left",-o+parseInt(a(d).position().left)):j.css("left",parseInt(a(d).position().left)),c.pinned&&j.css("left",o+parseInt(a(d).position().left)),void 0==O){j.prependTo(this.table),j[0].id="templateeditor"+this.element.id+r,this.editors["templateeditor_"+r]=j;var M=h.width()-1,N=h.height()-1;j.width(M),j.height(N),c.createeditor&&c.createeditor(b,k,j,l,M,N,this.editchar)}c._requirewidthupdate&&j.width(h.width()-2);break;case"textbox":default:d.innerHTML="",j=this.editors["textboxeditor_"+c.datafield]||a("<input autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' type='textbox' id='textboxeditor'/>"),j[0].id="textboxeditor"+this.element.id+c.datafield,j.appendTo(h),this.rtl&&j.css("direction","rtl"),(e||""==j[0].className)&&(j.addClass(this.toThemeProperty("jqx-input")),j.addClass(this.toThemeProperty("jqx-widget-content")),this.editchar&&this.editchar.length>0?j.val(this.editchar):(""!=c.cellsformat&&(k=this.getcelltext(b,g)),void 0==k&&(k=""),j.val(k)),void 0!=this.editcell.defaultvalue&&j.val(this.editcell.defaultvalue),j.width(h.width()+1),j.height(h.height()+1),c.createeditor&&c.createeditor(b,k,j),""!=c.cellsformat&&(c.cellsformat.indexOf("p")==-1&&c.cellsformat.indexOf("c")==-1&&c.cellsformat.indexOf("n")==-1&&c.cellsformat.indexOf("f")==-1||this.editors["textboxeditor_"+c.datafield]||j.keydown(function(a){var b=a.charCode?a.charCode:a.keyCode?a.keyCode:0,d=String.fromCharCode(b),e=parseInt(d);if(isNaN(e))return!0;if(i._selection(j).length>0)return!0;var f="",g=j.val();if(c.cellsformat.length>1){var h=parseInt(c.cellsformat.substring(1));isNaN(h)&&(h=0)}else var h=0;if(h>0&&g.indexOf(i.gridlocalization.decimalseparator)!=-1&&i._selection(j).start>g.indexOf(i.gridlocalization.decimalseparator))return!0;for(var k=0;k<g.length-h;k++){var l=g.substring(k,k+1);null!=l.match(/^[0-9]+$/)&&(f+=l)}return!(f.length>=11)&&void 0}))),this.editors["textboxeditor_"+c.datafield]=j,e&&f&&setTimeout(function(){q(j),i.editchar?(i._setSelection(j[0],1,1),i.editchar=null):i._setSelection(j[0],0,j.val().length)},25)}j&&(j[0].style.zIndex=1+parseInt(d.style.zIndex),a.jqx.browser.msie&&a.jqx.browser.version<8&&(j[0].style.zIndex=1+this.columns.records.length+d.style.zIndex),j.css("display","block"),this.editcell.editor=j,this.editcell[g]?this.editcell[g].editor=j:(this.editcell[g]={},this.editcell[g].editor=j)),e&&c.initeditor&&c.initeditor(b,k,j,l,this.editchar),i.isTouchDevice()||setTimeout(function(){i.content&&(i.content[0].scrollTop=0,i.content[0].scrollLeft=0),i.gridcontent&&(i.gridcontent[0].scrollLeft=0,i.gridcontent[0].scrollTop=0)},10)}},_setSelection:function(a,b,c){try{if("selectionStart"in a)a.setSelectionRange(b,c);else{var d=a.createTextRange();d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d.select()}}catch(a){}},_hideeditors:function(){if(null!=this.editcells){var a=this;for(var b in this.editcells)a.editcell=a.editcells[b],a._hidecelleditor()}},_hidecelleditor:function(a){if(this.editcell){if("selectedrow"===this.editmode){for(var b=0;b<this.columns.records.length;b++){var c=this.columns.records[b];if(this.editcell[c.datafield]&&this.editcell[c.datafield].editor){this.editcell[c.datafield].editor.hide();var d=this.editcell[c.datafield].editor;switch(c.columntype){case"dropdownlist":d.jqxDropDownList({closeDelay:0}),d.jqxDropDownList("hideListBox"),d.jqxDropDownList({closeDelay:300});break;case"combobox":d.jqxComboBox({closeDelay:0}),d.jqxComboBox("hideListBox"),d.jqxComboBox({closeDelay:300});break;case"datetimeinput":d.jqxDateTimeInput("isOpened")&&(d.jqxDateTimeInput({closeDelay:0}),d.jqxDateTimeInput("hideCalendar"),d.jqxDateTimeInput({closeDelay:300}))}}}return void(this.validationpopup&&(this.validationpopup.hide(),this.validationpopuparrow.hide()))}if("checkbox"!=this.editcell.columntype){if(this.editcell.editor)switch(this.editcell.editor.hide(),this.editcell.columntype){case"dropdownlist":this.editcell.editor.jqxDropDownList({closeDelay:0}),this.editcell.editor.jqxDropDownList("hideListBox"),this.editcell.editor.jqxDropDownList({closeDelay:300});break;case"combobox":this.editcell.editor.jqxComboBox({closeDelay:0}),this.editcell.editor.jqxComboBox("hideListBox"),this.editcell.editor.jqxComboBox({closeDelay:300});break;case"datetimeinput":var e=this.editcell.editor;e.jqxDateTimeInput("isOpened")&&(e.jqxDateTimeInput({closeDelay:0}),e.jqxDateTimeInput("hideCalendar"),e.jqxDateTimeInput({closeDelay:300}))}this.validationpopup&&(this.validationpopup.hide(),this.validationpopuparrow.hide()),this.isNestedGrid||0!=a&&this.element.focus()}}},_geteditorvalue:function(b){var c=new String;if(!this.editcell)return null;var d=this.editcell.editor;if("selectedrow"==this.editmode&&this.editcell[b.datafield])var d=this.editcell[b.datafield].editor;if(d){switch(b.columntype){case"textbox":default:if(c=d.val(),""!=b.cellsformat){var e="string",f=this.source.datafields||(this.source._source?this.source._source.datafields:null);if(f){var g="";a.each(f,function(){if(this.name==b.displayfield)return this.type&&(g=this.type),!1}),g&&(e=g)}var h="number"===e||"float"===e||"int"===e||"integer"===e,i="date"===e||"time"===e;if(h||"string"===e&&(b.cellsformat.indexOf("p")!=-1||b.cellsformat.indexOf("c")!=-1||b.cellsformat.indexOf("n")!=-1||b.cellsformat.indexOf("f")!=-1)){if(""===c&&b.nullable)return"";c.indexOf(this.gridlocalization.currencysymbol)>-1&&(c=c.replace(this.gridlocalization.currencysymbol,""));var j=function(a,b,c){var d=a;if(b==c)return a;for(var e=d.indexOf(b);e!=-1;)d=d.replace(b,c),e=d.indexOf(b);return d},k=c;if(k=new Number(k),!isNaN(k))return k;c=j(c,this.gridlocalization.thousandsseparator,""),c=c.replace(this.gridlocalization.decimalseparator,"."),c.indexOf(this.gridlocalization.percentsymbol)>-1&&(c=c.replace(this.gridlocalization.percentsymbol,""));for(var l="",m=0;m<c.length;m++){var n=c.substring(m,m+1);"-"===n&&(l+="-"),"."===n&&(l+="."),null!=n.match(/^[0-9]+$/)&&(l+=n)}c=l,c=c.replace(/ /g,""),c=new Number(c),isNaN(c)&&(c="")}if(i||"string"===e&&(b.cellsformat.indexOf("H")!=-1||b.cellsformat.indexOf("m")!=-1||b.cellsformat.indexOf("M")!=-1||b.cellsformat.indexOf("y")!=-1||b.cellsformat.indexOf("h")!=-1||b.cellsformat.indexOf("d")!=-1)){if(""===c&&b.nullable)return"";var o=c;a.jqx.dataFormat&&(c=a.jqx.dataFormat.tryparsedate(o,this.gridlocalization)),"Invalid Date"!=c&&null!=c||(c="")}}b.displayfield!=b.datafield&&(c={label:c,value:c});break;case"checkbox":d.jqxCheckBox&&(c=d.jqxCheckBox("checked"));break;case"datetimeinput":if(d.jqxDateTimeInput){if(d.jqxDateTimeInput({isEditing:!1}),d.jqxDateTimeInput("_validateValue"),c=d.jqxDateTimeInput("getDate"),null==c)return null;c=new Date(c.toString()),b.displayfield!=b.datafield&&(c={label:c,value:c})}break;case"dropdownlist":if(d.jqxDropDownList){var p=d.jqxDropDownList("selectedIndex"),q=d.jqxDropDownList("listBox").getVisibleItem(p);c=b.displayfield!=b.datafield?q?{label:q.label,value:q.value}:"":q?q.label:"",null==c&&(c="")}break;case"combobox":if(d.jqxComboBox){if(c=d.jqxComboBox("val"),b.displayfield!=b.datafield){var q=d.jqxComboBox("getSelectedItem");null!=q&&(c={label:q.label,value:q.value})}null==c&&(c="")}break;case"numberinput":if(d.jqxNumberInput){this.touchdevice&&d.jqxNumberInput("_doTouchHandling");var r=d.jqxNumberInput("getDecimal");c=new Number(r),c=parseFloat(c),isNaN(c)&&(c=0),null===r&&(c=null),b.displayfield!=b.datafield&&(c={label:c,value:c})}}b.geteditorvalue&&(c="selectedrow"==this.editmode?b.geteditorvalue(this.editcell.row,this.getcellvalue(this.editcell.row,b.datafield),d):b.geteditorvalue(this.editcell.row,this.editcell.value,d))}return c},hidevalidationpopups:function(){this.popups&&(a.each(this.popups,function(){this.validation.remove(),this.validationrow.remove()}),this.popups=new Array),this.validationpopup&&(this.validationpopuparrow.hide(),this.validationpopup.hide())},showvalidationpopup:function(b,c,d){if(void 0==d)var d=this.gridlocalization.validationstring;var e=a("<div style='z-index: 99999; top: 0px; left: 0px; position: absolute;'></div>"),f=a("<div style='width: 20px; height: 20px; z-index: 999999; top: 0px; left: 0px; position: absolute;'></div>");e.html(d),f.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up")),e.addClass(this.toThemeProperty("jqx-grid-validation")),e.addClass(this.toThemeProperty("jqx-rc-all")),e.prependTo(this.table),f.prependTo(this.table);for(var g=this.hScrollInstance,h=g.value,i=parseInt(h),j=this.getcolumn(c).uielement,k=null,l=0;l<this.hittestinfo.length;l++)b===this.hittestinfo[l].row.visibleindex&&(k=this.hittestinfo[l]);if(!k){this.ensurerowvisible(b);var m=this;return e.remove(),f.remove(),void setTimeout(function(){for(var a=null,e=0;e<m.hittestinfo.length;e++)b===m.hittestinfo[e].row.visibleindex&&(a=m.hittestinfo[e]);a&&m.showvalidationpopup(b,c,d)},25)}var n=a(k.visualrow);e.css("top",parseInt(n.position().top)+30+"px");var o=parseInt(e.css("top"));f.css("top",o-12),f.removeClass(),f.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));var p=!1;o>=this._gettableheight()&&(f.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-up")),f.addClass(this.toThemeProperty("jqx-grid-validation-arrow-down")),o=parseInt(n.position().top)-this.rowsheight-5,o<0&&(o=0,this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-down")),p=!0),e.css("top",o+"px"),f.css("top",o+e.outerHeight()-9));var q=-i+parseInt(a(j).position().left);f.css("left",i+q+30);var r=e.width();if(r+q>this.host.width()-20){var s=r+q-this.host.width()+40;q-=s}p?e.css("left",i+parseInt(a(j).position().left)-e.outerWidth()):e.css("left",i+q),e.show(),f.show(),this.popups||(this.popups=new Array),this.popups[this.popups.length]={validation:e,validationrow:f}},_showvalidationpopup:function(b,c,d){var e=this.editcell,f=this.editcell.editor;if("selectedrow"==this.editmode){var e=this.editcell[c];e&&e.editor&&(f=e.editor,e.element=f)}if(f&&!(this.validationpopup&&a.jqx.isHidden(this.validationpopup)&&(this.validationpopup.remove&&(this.validationpopup.remove(),this.validationpopuparrow.remove()),this.validationpopup=null,this.validationpopuparrow=null,void 0===c&&void 0===d&&this.editors&&0===this.editors.length))){if(this.validationpopup)this.validationpopup.html(d);else{var g=a("<div style='z-index: 99999; top: 0px; left: 0px; position: absolute;'></div>"),h=a("<div style='width: 20px; height: 20px; z-index: 999999; top: 0px; left: 0px; position: absolute;'></div>");g.html(d),h.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up")),g.addClass(this.toThemeProperty("jqx-grid-validation")),g.addClass(this.toThemeProperty("jqx-rc-all")),g.prependTo(this.table),h.prependTo(this.table),this.validationpopup=g,this.validationpopuparrow=h}var i=this.hScrollInstance,j=i.value,k=parseInt(j);"selectedrow"==this.editmode?this.visiblerows&&this.visiblerows[this.editcell.visiblerowindex]?this.validationpopup.css("top",this.visiblerows[this.editcell.visiblerowindex].top+(this.rowsheight+5)+"px"):this.validationpopup.css("top",parseInt(a(e.editor).position().top)+(this.rowsheight+5)+"px"):this.validationpopup.css("top",parseInt(a(e.element).parent().position().top)+(this.rowsheight+5)+"px");var l=parseInt(this.validationpopup.css("top"));this.validationpopuparrow.css("top",l-11),this.validationpopuparrow.removeClass(),this.validationpopuparrow.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));var m=this._gettableheight(),n=!1;l>=m&&(this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-up")),this.validationpopuparrow.addClass(this.toThemeProperty("jqx-grid-validation-arrow-down")),l=parseInt(a(e.element).parent().position().top)-this.rowsheight-5,"selectedrow"==this.editmode&&(l=this.visiblerows&&this.visiblerows[this.editcell.visiblerowindex]?this.visiblerows[this.editcell.visiblerowindex].top-this.rowsheight-5:parseInt(a(e.editor).position().top)-this.rowsheight-5),l<0&&(l=0,this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-down")),n=!0),this.validationpopup.css("top",l+"px"),this.validationpopuparrow.css("top",l+this.validationpopup.outerHeight()-9));var o=-k+parseInt(a(e.element).position().left);this.validationpopuparrow.css("left",k+o+30);var p=this.validationpopup.width();if(p+o>this.host.width()-20){var q=p+o-this.host.width()+40;o-=q}n?this.validationpopup.css("left",k+parseInt(a(e.element).position().left)-this.validationpopup.outerWidth()):this.validationpopup.css("left",k+o),"none"==this.editcell.editor.css("display")?(this.validationpopup.hide(),this.validationpopuparrow.hide()):(this.validationpopup.show(),this.validationpopuparrow.show())}}})}(jqxBaseFramework);
2d1d43c3a2c2 Upgraded jqwidgets to version 4.5.2
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
8

mercurial