jqxgrid.edit.js 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. /*
  2. jQWidgets v8.1.4 (2019-July)
  3. Copyright (c) 2011-2019 jQWidgets.
  4. License: https://jqwidgets.com/license/
  5. */
  6. /* eslint-disable */
  7. (function (a) {
  8. a.extend(a.jqx._jqxGrid.prototype, {
  9. _handledblclick: function (t, n) {
  10. if (t.target == null) {return;}
  11. if (n.disabled) {return;}
  12. if (a(t.target).ischildof(this.columnsheader)) {return;}
  13. var w;
  14. if (t.which) {w = (t.which == 3);} else {if (t.button) {w = (t.button == 2);}}
  15. if (w) {return;}
  16. var B;
  17. if (t.which) {B = (t.which == 2);} else {if (t.button) {B = (t.button == 1);}}
  18. if (B) {return;}
  19. var v = this.showheader ? this.columnsheader.height() + 2 : 0;
  20. var o = this._groupsheader() ? this.groupsheader.height() : 0;
  21. var A = this.showtoolbar ? this.toolbarheight : 0;
  22. o += A;
  23. var e = this.host.offset();
  24. var m = t.pageX - e.left;
  25. var l = t.pageY - v - e.top - o;
  26. var b = this._hittestrow(m, l);
  27. if (!b) {return;}
  28. var h = b.row;
  29. var j = b.index;
  30. var q = t.target.className;
  31. var p = this.table[0].rows[j];
  32. if (p == null) {return;}
  33. n.mousecaptured = true;
  34. n.mousecaptureposition = { left: t.pageX, top: t.pageY - o };
  35. var r = this.hScrollInstance;
  36. var s = r.value;
  37. var d = 0;
  38. var k = this.groupable ? this.groups.length : 0;
  39. for (var u = 0; u < p.cells.length; u++) {
  40. var f = parseInt(a(this.columnsrow[0].cells[u]).css("left"));
  41. var g = f - s;
  42. if (n.columns.records[u].pinned) {g = f;}
  43. var c = this._getcolumnat(u);
  44. if (c != null && c.hidden) {continue;}
  45. var z = g + a(this.columnsrow[0].cells[u]).width();
  46. if (z >= m && m >= g) {
  47. d = u;
  48. break;
  49. }
  50. }
  51. if (h != null) {
  52. var c = this._getcolumnat(d);
  53. if (!(q.indexOf("jqx-grid-group-expand") != -1 || q.indexOf("jqx-grid-group-collapse") != -1)) {if (h.boundindex != -1) {n.begincelledit(n.getboundindex(h), c.datafield, c.defaulteditorvalue);}}
  54. }
  55. }, _getpreveditablecolumn: function (c) {
  56. var b = this;
  57. while (c > 0) {
  58. c--;
  59. var d = b.getcolumnat(c);
  60. if (!d) {return null;}
  61. if (!d.editable) {continue;}
  62. if (!d.hidden) {return d;}
  63. }
  64. return null;
  65. }, _getnexteditablecolumn: function (c) {
  66. var b = this;
  67. while (c < this.columns.records.length) {
  68. c++;
  69. var d = b.getcolumnat(c);
  70. if (!d) {return null;}
  71. if (!d.editable) {continue;}
  72. if (!d.hidden) {return d;}
  73. }
  74. return null;
  75. }, _handleeditkeydown: function (T, j) {
  76. if (j.handlekeyboardnavigation) {
  77. var L = j.handlekeyboardnavigation(T);
  78. if (L == true) {return true;}
  79. }
  80. var u = T.charCode ? T.charCode : T.keyCode ? T.keyCode : 0;
  81. j.editEvent = T;
  82. if (j.showfilterrow && j.filterable) {if (this.filterrow) {if (a(T.target).ischildof(this.filterrow)) {return true;}}}
  83. if (T.target.className && T.target.className.indexOf("jqx-grid-widget") >= 0) {return true;}
  84. if (j.pageable) {if (a(T.target).ischildof(this.pager)) {return true;}}
  85. if (this.showtoolbar) {if (a(T.target).ischildof(this.toolbar)) {return true;}}
  86. if (this.showeverpresentrow) {
  87. if (this.addnewrowtop) {if (a(T.target).ischildof(this.addnewrowtop)) {return true;}}
  88. if (this.addnewrowbottom) {if (a(T.target).ischildof(this.addnewrowbottom)) {return true;}}
  89. }
  90. if (this.showstatusbar) {if (a(T.target).ischildof(this.statusbar)) {return true;}}
  91. if (this.rowdetails) {if (a(T.target).ischildof(this.content.find("[role='rowgroup']"))) {return true;}}
  92. if (this.editcell) {
  93. if (this.editmode === "selectedrow") {
  94. if (u === 13) {
  95. this.endrowedit(this.editcell.row, false);
  96. return false;
  97. } else {
  98. if (u === 27) {
  99. this.endrowedit(this.editcell.row, true);
  100. return false;
  101. }
  102. }
  103. if (u == 32) {
  104. if (this._currentColumn && this.getcolumn(this._currentColumn).columntype == "checkbox") {
  105. var M = this.getcolumn(this._currentColumn);
  106. if (M.editable) {
  107. var A = !this.getcellvalue(this.editcell.row, M.datafield);
  108. var H = this.getrowdata(this.editcell.row);
  109. var s = this.editcell.row;
  110. var H = j.getrowdata(j.editcell.row);
  111. this.setcellvalue(this.editcell.row, M.datafield, A, false);
  112. var k = this._focusedColumn;
  113. var d = this._currentColumn;
  114. var f = this._currentEditableColumn;
  115. this.endrowedit(this.editcell.row, false);
  116. this.beginrowedit(s, false);
  117. this._currentColumn = d;
  118. this._focusedColumn = k;
  119. this._currentEditableColumn = f;
  120. this._renderrows();
  121. this.selectcell(s, M.datafield);
  122. this._oldselectedcell = this.selectedcell;
  123. if (k) {
  124. var G = this;
  125. setTimeout(function () {
  126. G.selectcell(s, M.datafield);
  127. G._oldselectedcell = G.selectedcell;
  128. a(G._checkboxCells[M.datafield].checkbox).jqxCheckBox("focus");
  129. }, 25);
  130. }
  131. return false;
  132. }
  133. }
  134. }
  135. if (u === 9) {
  136. var K = this.editcell.datafield;
  137. var e = this._getcolumnindex(K);
  138. if (this._currentEditableColumn) {e = this._currentEditableColumn;} else {this._currentEditableColumn = e;}
  139. var M = this._getnexteditablecolumn(e);
  140. if (T.shiftKey) {M = this._getpreveditablecolumn(e);}
  141. if (M) {
  142. var e = this._getcolumnindex(M.datafield);
  143. if (this.editcell[M.datafield]) {
  144. this._currentEditableColumn = e;
  145. var b = this.editcell[M.datafield].editor;
  146. if (b) {
  147. if (b.data().jqxWidget && b.data().jqxWidget.focus) {b.data().jqxWidget.focus();} else {
  148. b.focus();
  149. b[0].onkeyup = function () {
  150. if (j.gridcontent[0].scrollTop != 0) {
  151. j.scrolltop(Math.abs(j.gridcontent[0].scrollTop));
  152. j.gridcontent[0].scrollTop = 0;
  153. }
  154. if (j.gridcontent[0].scrollLeft != 0) {j.gridcontent[0].scrollLeft = 0;}
  155. };
  156. }
  157. }
  158. this._focusedColumn = M.datafield;
  159. this._currentColumn = M.datafield;
  160. if (this.gridcontent[0].scrollTop != 0) {
  161. this.scrolltop(Math.abs(this.gridcontent[0].scrollTop));
  162. this.gridcontent[0].scrollTop = 0;
  163. }
  164. if (this.gridcontent[0].scrollLeft != 0) {this.gridcontent[0].scrollLeft = 0;}
  165. } else {
  166. if (M.columntype == "checkbox") {
  167. this._currentColumn = M.datafield;
  168. this._currentEditableColumn = e;
  169. this.selectcell(this.editcell.row, M.datafield);
  170. this._oldselectedcell = this.selectedcell;
  171. if (this._checkboxCells[M.datafield]) {a(this._checkboxCells[M.datafield].checkbox).jqxCheckBox("focus");}
  172. return false;
  173. }
  174. }
  175. }
  176. return false;
  177. }
  178. return true;
  179. }
  180. if (this.editcell.columntype == null || this.editcell.columntype == "textbox" || this.editcell.columntype == "numberinput" || this.editcell.columntype == "combobox" || this.editcell.columntype == "datetimeinput") {
  181. if (u >= 33 && u <= 40 && j.selectionmode == "multiplecellsadvanced") {
  182. var b = this.editcell.columntype == "textbox" || this.editcell.columntype == null ? this.editcell.editor : this.editcell.editor.find("input");
  183. var p = j._selection(b);
  184. var J = b.val().length;
  185. if (p.length > 0 && this.editcell.columntype != "datetimeinput") {j._cancelkeydown = true;}
  186. if (p.start > 0 && u == 37) {j._cancelkeydown = true;}
  187. if (p.start < J && u == 39 && this.editcell.columntype != "datetimeinput") {j._cancelkeydown = true;}
  188. if (this.editcell.columntype == "datetimeinput" && u == 39) {if (p.start + p.length < J) {j._cancelkeydown = true;}}
  189. }
  190. } else {if (this.editcell.columntype == "dropdownlist") {if (u == 37 || u == 39 && j.selectionmode == "multiplecellsadvanced") {j._cancelkeydown = false;}} else {if (this.selectionmode == "multiplecellsadvanced" && this.editcell.columntype != "textbox" && this.editcell.columntype != "numberinput") {j._cancelkeydown = true;}}}
  191. if (u == 32) {
  192. if (j.editcell.columntype == "checkbox") {
  193. var M = j.getcolumn(j.editcell.datafield);
  194. if (M.editable) {
  195. var A = !j.getcellvalue(j.editcell.row, j.editcell.column);
  196. if (M.cellbeginedit) {
  197. var n = M.cellbeginedit(j.editcell.row, M.datafield, M.columntype, !A);
  198. if (n == false) {return false;}
  199. }
  200. var H = j.getrowdata(j.editcell.row);
  201. j.setcellvalue(j.editcell.row, j.editcell.column, A, true);
  202. j._raiseEvent(18, { rowindex: j.editcell.row, row: H, datafield: j.editcell.column, oldvalue: !A, value: A, columntype: "checkbox" });
  203. return false;
  204. }
  205. }
  206. }
  207. if (u == 9) {
  208. var l = this.editcell.row;
  209. var K = this.editcell.column;
  210. var i = K;
  211. var e = j._getcolumnindex(K);
  212. var D = false;
  213. var I = j.getrowvisibleindex(l);
  214. var N = l;
  215. this.editchar = "";
  216. var t = this.editcell.validated;
  217. if (!this.editcell.validated) {var t = this.endcelledit(this.editcell.row, this.editcell.column, false, true, false);}
  218. if (t != false) {
  219. if (T.shiftKey) {
  220. var M = j._getpreveditablecolumn(e);
  221. if (M) {
  222. K = M.datafield;
  223. D = true;
  224. if (j.selectionmode.indexOf("cell") != -1) {
  225. j.selectprevcell(l, i);
  226. j._oldselectedcell = j.selectedcell;
  227. setTimeout(function () {j.ensurecellvisible(I, K);}, 10);
  228. }
  229. } else {
  230. var r = j._getlastvisiblecolumn();
  231. D = true;
  232. K = r.displayfield;
  233. var h = j.getdisplayrows()[I - 1];
  234. if (h) {
  235. l = h.dataindex;
  236. if (l === undefined) {l = h.boundindex;}
  237. I = j.getrowvisibleindex(l);
  238. }
  239. var y = true;
  240. if (j.pageable) {
  241. var Q = Math.floor(I / this.pagesize);
  242. if (this.dataview.pagenum != Q) {y = false;}
  243. }
  244. if (y && j.selectionmode.indexOf("cell") != -1) {
  245. j.clearselection();
  246. j.selectcell(l, K);
  247. j._oldselectedcell = j.selectedcell;
  248. setTimeout(function () {j.ensurecellvisible(I, K);}, 10);
  249. }
  250. }
  251. } else {
  252. var M = j._getnexteditablecolumn(e);
  253. if (M) {
  254. K = M.datafield;
  255. D = true;
  256. if (j.selectionmode.indexOf("cell") != -1) {
  257. j.selectnextcell(l, i);
  258. j._oldselectedcell = j.selectedcell;
  259. setTimeout(function () {j.ensurecellvisible(I, K);}, 10);
  260. }
  261. } else {
  262. var x = j._getfirstvisiblecolumn();
  263. D = true;
  264. K = x.displayfield;
  265. var h = j.getdisplayrows()[I + 1];
  266. if (h) {
  267. l = h.dataindex;
  268. if (l === undefined) {l = h.boundindex;}
  269. I = j.getrowvisibleindex(l);
  270. }
  271. var y = true;
  272. if (j.pageable) {
  273. var Q = Math.floor(I / this.pagesize);
  274. if (this.dataview.pagenum != Q) {y = false;}
  275. }
  276. if (j.selectionmode.indexOf("cell") != -1) {
  277. if (y) {
  278. j.clearselection();
  279. j.selectcell(l, K);
  280. j._oldselectedcell = j.selectedcell;
  281. setTimeout(function () {j.ensurecellvisible(I, K);}, 10);
  282. }
  283. }
  284. }
  285. }
  286. if (D) {
  287. if (j.pageable) {
  288. var Q = Math.floor(I / this.pagesize);
  289. if (this.dataview.pagenum != Q) {
  290. this._renderrows(this.virtualsizeinfo);
  291. if (j.selectionmode.indexOf("cell") != -1) {
  292. j.clearselection();
  293. j.selectcell(N, i);
  294. j._oldselectedcell = j.selectedcell;
  295. }
  296. if (Q > this.dataview.pagenum) {setTimeout(function () {j.pagerpageinput.focus();}, 25);}
  297. return;
  298. }
  299. }
  300. j.begincelledit(l, K);
  301. if (this.editcell != null && this.editcell.columntype == "checkbox") {this._renderrows(this.virtualsizeinfo);}
  302. } else {
  303. if (this.editcell != null) {
  304. j.endcelledit(l, K, false);
  305. this._renderrows(this.virtualsizeinfo);
  306. }
  307. return true;
  308. }
  309. }
  310. return false;
  311. } else {
  312. if (u == 13) {
  313. var F = this.selectedcell;
  314. if (F) {var z = this.getrowvisibleindex(F.rowindex);}
  315. this.endcelledit(this.editcell.row, this.editcell.column, false, true);
  316. if (this.selectionmode == "multiplecellsadvanced") {
  317. var B = j.getselectedcell();
  318. if (B != null) {
  319. if (j.selectcell) {
  320. if (this.editcell == null) {
  321. if (B.rowindex + 1 < this.dataview.totalrecords) {
  322. if (this.sortcolumn != B.datafield) {
  323. var I = this.getrowvisibleindex(B.rowindex);
  324. var q = this.dataview.loadedrecords[I + 1];
  325. if (q) {
  326. if (!this.pageable || (this.pageable && I + 1 < (this.dataview.pagenum + 1) * this.pagesize)) {
  327. this.clearselection(false);
  328. this.selectcell(this.getboundindex(q), B.datafield);
  329. var B = this.getselectedcell();
  330. this.ensurecellvisible(q.visibleindex, B.datafield);
  331. }
  332. }
  333. } else {
  334. if (F != null) {
  335. var S = this.dataview.loadedrecords[z + 1];
  336. if (S) {
  337. if (!this.pageable || (this.pageable && z + 1 < this.pagesize)) {
  338. this.clearselection(false);
  339. this.selectcell(this.getboundindex(S), B.datafield);
  340. } else {
  341. if (this.pageable && z + 1 >= this.pagesize) {
  342. this.clearselection(false);
  343. var S = this.dataview.loadedrecords[z];
  344. this.selectcell(this.getboundindex(S), B.datafield);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. return false;
  356. } else {
  357. if (u == 27) {
  358. this.endcelledit(this.editcell.row, this.editcell.column, true, true);
  359. return false;
  360. }
  361. }
  362. }
  363. } else {
  364. var O = false;
  365. if (u == 113) {O = true;}
  366. if (!T.ctrlKey && !T.altKey && !T.metaKey) {
  367. if (u >= 48 && u <= 57) {
  368. this.editchar = String.fromCharCode(u);
  369. O = true;
  370. }
  371. if (u === 189) {O = true;}
  372. if (u >= 65 && u <= 90) {
  373. this.editchar = String.fromCharCode(u);
  374. var o = false;
  375. if (T.shiftKey) {o = T.shiftKey;} else {if (T.modifiers) {o = !!(T.modifiers & 4);}}
  376. if (this._capsLock) {o = !o;}
  377. if (!o) {this.editchar = this.editchar.toLowerCase();}
  378. O = true;
  379. } else {
  380. if (u >= 96 && u <= 105) {
  381. this.editchar = u - 96;
  382. this.editchar = this.editchar.toString();
  383. O = true;
  384. }
  385. }
  386. var C = a(".jqx-grid").length;
  387. O = O && (C == 1 || (C > 1 && j.focused));
  388. var R = a.data(document.body, "jqxgrid.edit");
  389. if (R !== undefined && R !== "") {if (u === 13 || O) {if (R != j.element.id) {return true;}}}
  390. }
  391. if (u == 13 || O) {
  392. if (j.getselectedrowindex) {
  393. var l = j.getselectedrowindex();
  394. if (j.editmode === "selectedrow") {
  395. if (l >= 0) {j.beginrowedit(l);} else {
  396. var B = j.getselectedcell();
  397. if (B != null) {
  398. var M = j._getcolumnbydatafield(B.datafield);
  399. j.beginrowedit(B.rowindex);
  400. }
  401. return false;
  402. }
  403. }
  404. switch (j.selectionmode) {
  405. case"singlerow":
  406. case"multiplerows":
  407. case"multiplerowsextended":
  408. if (l >= 0) {
  409. var K = "";
  410. for (var P = 0; P < j.columns.records.length; P++) {
  411. var M = j.getcolumnat(P);
  412. if (M.editable) {
  413. K = M.datafield;
  414. break;
  415. }
  416. }
  417. if (j.editmode === "selectedrow") {j.beginrowedit(l);} else {j.begincelledit(l, K);}
  418. }
  419. break;
  420. case"singlecell":
  421. case"multiplecells":
  422. case"multiplecellsextended":
  423. var B = j.getselectedcell();
  424. if (B != null) {
  425. var M = j._getcolumnbydatafield(B.datafield);
  426. if (j.editmode === "selectedrow") {j.beginrowedit(B.rowindex);} else {if (M.columntype != "checkbox") {j.begincelledit(B.rowindex, B.datafield);}}
  427. }
  428. break;
  429. case"multiplecellsadvanced":
  430. var B = j.getselectedcell();
  431. if (B != null) {
  432. if (u == 13) {
  433. if (j.selectcell) {
  434. var I = this.getrowvisibleindex(B.rowindex);
  435. if (I + 1 < j.dataview.totalrecords) {
  436. var q = this.dataview.loadedrecords[I + 1];
  437. if (q) {
  438. this.clearselection(false);
  439. this.selectcell(this.getboundindex(q), B.datafield);
  440. var B = this.getselectedcell();
  441. this.ensurecellvisible(q.visibleindex, B.datafield);
  442. }
  443. }
  444. }
  445. } else {if (j.editmode !== "selectedrow") {j.begincelledit(B.rowindex, B.datafield);}}
  446. }
  447. break;
  448. }
  449. return false;
  450. }
  451. }
  452. if (u == 46) {
  453. var v = j.getselectedcells();
  454. if (j.selectionmode.indexOf("cell") == -1) {if (j._getcellsforcopypaste) {v = j._getcellsforcopypaste();}}
  455. if (v != null && v.length > 0) {
  456. for (var w = 0; w < v.length; w++) {
  457. var B = v[w];
  458. if (!B.datafield) {continue;}
  459. var M = j.getcolumn(B.datafield);
  460. var E = j.getcellvalue(B.rowindex, B.datafield);
  461. if (E !== "" && M.editable && j.enablekeyboarddelete) {
  462. var c = null;
  463. if (M.columntype == "checkbox") {if (!M.threestatecheckbox) {c = false;}}
  464. if (M.cellbeginedit) {
  465. var n = M.cellbeginedit(B.rowindex, M.datafield, M.columntype, c);
  466. if (n == false) {return false;}
  467. }
  468. var H = j.getrowdata(B.rowindex);
  469. j._raiseEvent(17, { rowindex: B.rowindex, row: H, datafield: B.datafield, value: E });
  470. if (w == v.length - 1) {
  471. j.setcellvalue(B.rowindex, B.datafield, c, true);
  472. if (M.displayfield != M.datafield) {j.setcellvalue(B.rowindex, M.displayfield, c, true);}
  473. } else {
  474. j.setcellvalue(B.rowindex, B.datafield, c, false);
  475. if (M.displayfield != M.datafield) {j.setcellvalue(B.rowindex, M.displayfield, c, true);}
  476. }
  477. if (M.cellendedit) {var g = M.cellendedit(B.rowindex, M.datafield, M.columntype, c);}
  478. j._raiseEvent(18, { rowindex: B.rowindex, row: H, datafield: B.datafield, oldvalue: E, value: c });
  479. }
  480. }
  481. this.dataview.updateview();
  482. this._renderrows(this.virtualsizeinfo);
  483. return false;
  484. }
  485. }
  486. if (u == 32) {
  487. var B = j.getselectedcell();
  488. if (B != null) {
  489. var M = j.getcolumn(B.datafield);
  490. if (M.columntype == "checkbox" && M.editable) {
  491. var A = !j.getcellvalue(B.rowindex, B.datafield);
  492. if (M.cellbeginedit) {
  493. var n = M.cellbeginedit(B.rowindex, M.datafield, M.columntype, !A);
  494. if (n == false) {return false;}
  495. }
  496. var H = j.getrowdata(B.rowindex);
  497. j._raiseEvent(17, { rowindex: B.rowindex, row: H, datafield: B.datafield, value: !A, columntype: "checkbox" });
  498. j.setcellvalue(B.rowindex, B.datafield, A, true);
  499. j._raiseEvent(18, { rowindex: B.rowindex, row: H, datafield: B.datafield, oldvalue: !A, value: A, columntype: "checkbox" });
  500. return false;
  501. }
  502. }
  503. }
  504. }
  505. return true;
  506. }, begincelledit: function (o, e, l, g, c) {
  507. var f = this.getcolumn(e);
  508. this._cellscache = new Array();
  509. if (e == null) {return;}
  510. if (f.columntype == "number" || f.columntype == "button" || f.createwidget) {return;}
  511. if (this.groupable) {
  512. if (this.groups.indexOf(e) >= 0) {return;}
  513. if (this.groups.indexOf(f.displayfield) >= 0) {return;}
  514. }
  515. if (this.editrow != undefined) {return;}
  516. if (this.editcell) {
  517. if (this.editcell.row == o && this.editcell.column == e) {return true;}
  518. if (this.editmode === "selectedrow") {if (this.editcell.row == o) {return;}}
  519. var d = this.endcelledit(this.editcell.row, this.editcell.column, false, true, false);
  520. if (false == d) {return;}
  521. }
  522. var i = f.columntype == "checkbox" || f.columntype == "button" || f.createwidget;
  523. this.host.removeClass("jqx-disableselect");
  524. this.content.removeClass("jqx-disableselect");
  525. if (f.editable) {
  526. if (f.cellbeginedit) {
  527. var k = this.getcell(o, e);
  528. var m = f.cellbeginedit(o, e, f.columntype, k != null ? k.value : null);
  529. if (m == false) {return;}
  530. }
  531. var j = this.getrowvisibleindex(o);
  532. this.editcell = this.getcell(o, e);
  533. if (this.editcell) {
  534. this.editcell.visiblerowindex = j;
  535. if (!this.editcell.editing) {
  536. if (!i) {this.editcell.editing = true;}
  537. this.editcell.columntype = f.columntype;
  538. this.editcell.defaultvalue = l;
  539. if (f.defaultvalue != undefined) {this.editcell.defaultvalue = f.defaultvalue;}
  540. this.editcell.init = true;
  541. if (f.columntype != "checkbox" && this.editmode != "selectedrow") {
  542. var h = this.getrowdata(o);
  543. this._raiseEvent(17, { rowindex: o, row: h, datafield: f.datafield, value: this.editcell.value, columntype: f.columntype });
  544. }
  545. a.data(document.body, "jqxgrid.edit", this.element.id);
  546. if (!i) {
  547. var b = this.getrowvisibleindex(o);
  548. if (g !== false) {if (!this.autorowheight && this.groups.length === 0) {var n = this.ensurecellvisible(b, f.datafield);}}
  549. if (c !== false) {this._renderrows(this.virtualsizeinfo);}
  550. }
  551. if (this.editcell) {
  552. this.editcell.init = false;
  553. return true;
  554. }
  555. }
  556. }
  557. } else {
  558. if (!this.editcell) {return;}
  559. this.editcell.editor = null;
  560. this.editcell.editing = false;
  561. if (c !== false) {this._renderrows(this.virtualsizeinfo);}
  562. this.editcell = null;
  563. }
  564. }, getScrollTop: function () {
  565. if (this._py) {return this._py;}
  566. this._py = typeof pageYOffset != "undefined";
  567. if (this._py) {return pageYOffset;} else {
  568. var c = document.body;
  569. var b = document.documentElement;
  570. b = (b.clientHeight) ? b : c;
  571. return b.scrollTop;
  572. }
  573. }, getScrollLeft: function () {
  574. if (typeof pageXOffset != "undefined") {return pageXOffset;} else {
  575. var c = document.body;
  576. var b = document.documentElement;
  577. b = (b.clientHeight) ? b : c;
  578. return b.scrollLeft;
  579. }
  580. }, endcelledit: function (h, o, k, e, p) {
  581. if (h == undefined || o == undefined) {
  582. if (this.editcell) {
  583. h = this.editcell.row;
  584. o = this.editcell.column;
  585. }
  586. if (k == undefined) {k = true;}
  587. }
  588. if (!this.editcell) {return;}
  589. var d = this.getcolumn(o);
  590. var v = this;
  591. if (v.editmode === "selectedrow") {
  592. this.endrowedit(h, k);
  593. return;
  594. }
  595. var u = function () {
  596. if (p != false) {
  597. if (v.isTouchDevice()) {return;}
  598. if (!v.isNestedGrid) {
  599. var w = v.getScrollTop();
  600. var y = v.getScrollLeft();
  601. try {
  602. v.element.focus();
  603. v.content.focus();
  604. if (w != v.getScrollTop()) {window.scrollTo(y, w);}
  605. setTimeout(function () {
  606. v.element.focus();
  607. v.content.focus();
  608. if (w != v.getScrollTop()) {window.scrollTo(y, w);}
  609. }, 10);
  610. } catch (x) {}
  611. }
  612. }
  613. };
  614. if (d.columntype == "checkbox" || d.columntype == "button" || d.createwidget) {
  615. if (this.editcell) {
  616. this.editcell.editor = null;
  617. this.editcell.editing = false;
  618. this.editcell = null;
  619. }
  620. return true;
  621. }
  622. var i = this._geteditorvalue(d);
  623. var g = function (x) {
  624. x._hidecelleditor();
  625. if (d.cellendedit) {d.cellendedit(h, o, d.columntype, x.editcell.value, i);}
  626. x.editchar = null;
  627. var z;
  628. if (d.displayfield != d.datafield) {
  629. var w = x.getcellvalue(x.editcell.row, d.displayfield);
  630. var y = x.editcell.value;
  631. z = { value: y, label: w };
  632. } else {z = x.editcell.value;}
  633. var A = x.getrowdata(h);
  634. x._raiseEvent(18, { rowindex: h, row: A, datafield: o, displayfield: d.displayfield, oldvalue: i, value: i, columntype: d.columntype });
  635. x.editcell.editor = null;
  636. x.editcell.editing = false;
  637. x.editcell = null;
  638. if (e || e == undefined) {x._renderrows(x.virtualsizeinfo);}
  639. u();
  640. if (!x.enablebrowserselection) {
  641. x.host.addClass("jqx-disableselect");
  642. x.content.addClass("jqx-disableselect");
  643. }
  644. };
  645. if (k) {
  646. g(this);
  647. return false;
  648. }
  649. if (this.validationpopup) {
  650. this.validationpopup.hide();
  651. this.validationpopuparrow.hide();
  652. }
  653. if (d.cellvaluechanging) {
  654. var b = d.cellvaluechanging(h, o, d.columntype, this.editcell.value, i);
  655. if (b != undefined) {i = b;}
  656. }
  657. if (d.validation) {
  658. var c = this.getcell(h, o);
  659. try {
  660. var q = d.validation(c, i);
  661. var m = this.gridlocalization.validationstring;
  662. if (q.message != undefined) {m = q.message;}
  663. var n = typeof q == "boolean" ? q : q.result;
  664. if (!n) {
  665. if (q.showmessage == undefined || q.showmessage == true) {this._showvalidationpopup(h, o, m);}
  666. this.editcell.validated = false;
  667. return false;
  668. }
  669. } catch (s) {
  670. this._showvalidationpopup(h, o, this.gridlocalization.validationstring);
  671. this.editcell.validated = false;
  672. return false;
  673. }
  674. }
  675. var j;
  676. if (d.displayfield != d.datafield) {
  677. var l = this.getcellvalue(this.editcell.row, d.displayfield);
  678. var r = this.editcell.value;
  679. j = { value: r, label: l };
  680. } else {j = this.editcell.value;}
  681. var f = this.getrowdata(h);
  682. if (d.cellendedit) {
  683. var t = d.cellendedit(h, o, d.columntype, this.editcell.value, i);
  684. if (t == false) {
  685. this._raiseEvent(18, { rowindex: h, row: f, datafield: o, displayfield: d.displayfield, oldvalue: j, value: j, columntype: d.columntype });
  686. g(this);
  687. return false;
  688. }
  689. }
  690. this._raiseEvent(18, { rowindex: h, row: f, datafield: o, displayfield: d.displayfield, oldvalue: j, value: i, columntype: d.columntype });
  691. this._hidecelleditor(false);
  692. if (this.editcell != undefined) {
  693. this.editcell.editor = null;
  694. this.editcell.editing = false;
  695. }
  696. this.editcell = null;
  697. this.editchar = null;
  698. this.setcellvalue(h, o, i, e);
  699. if (!this.enablebrowserselection) {
  700. this.host.addClass("jqx-disableselect");
  701. this.content.addClass("jqx-disableselect");
  702. }
  703. if (!a.jqx.browser.msie) {u();}
  704. a.data(document.body, "jqxgrid.edit", "");
  705. return true;
  706. }, beginrowedit: function (f) {
  707. var e = this;
  708. var g = -1;
  709. if (f == undefined) {return;}
  710. e._oldselectedrow = f;
  711. this._cellscache = new Array();
  712. var c = false;
  713. if (this.editmode != "selectedrow") {c = true;}
  714. if (c) {
  715. var b = this.editmode;
  716. this.editmode = "selectedrow";
  717. }
  718. var d = null;
  719. if (this._currentEditableColumn) {d = this.getcolumnat(this._currentEditableColumn).datafield;}
  720. a.each(this.columns.records, function (i, k) {
  721. if (e.editable && this.editable) {
  722. if (this.columntype === "checkbox" || this.columntype === "custom" || this.columntype === "widget" || this.columntype === "template" || this.columntype === "button") {return true;}
  723. if (!d) {d = this.datafield;}
  724. var h = e.getcell(f, this.datafield);
  725. e.begincelledit(f, this.datafield, null, false, false);
  726. var j = e.getrowdata(f);
  727. e._raiseEvent(17, { rowindex: f, row: j, datafield: this.datafield, value: h.value, columntype: this.columntype });
  728. }
  729. });
  730. if (e.editcell) {e.editcell.init = true;}
  731. this._renderrows(this.virtualsizeinfo);
  732. if (c) {this.editmode = b;}
  733. if (d && e.editcell) {
  734. /*luoyifan 不要主动跳转到第一个编辑器上*/
  735. //setTimeout(function () {
  736. // if (e.editcell && e.editcell[d]) {
  737. // var h = e.editcell[d].editor;
  738. // if (h) {if (h.data().jqxWidget && h.data().jqxWidget.focus) {h.data().jqxWidget.focus();} else {h.focus();}}
  739. // }
  740. //}, 25);
  741. }
  742. }, endrowedit: function (k, o) {
  743. var D = this;
  744. this._currentEditableColumn = 0;
  745. this._focusedColumn = null;
  746. this._currentColumn = null;
  747. this._checkboxCells = [];
  748. if (!this.editcell) {return false;}
  749. if (this.editcell.editor == undefined && this.editcell.columntype !== "checkbox") {return false;}
  750. var C = function () {
  751. if (focus != false) {
  752. if (D.isTouchDevice()) {return;}
  753. if (!D.isNestedGrid) {
  754. var i = D.getScrollTop();
  755. var F = D.getScrollLeft();
  756. try {
  757. D.element.focus();
  758. D.content.focus();
  759. if (i != D.getScrollTop()) {window.scrollTo(F, i);}
  760. setTimeout(function () {
  761. D.element.focus();
  762. D.content.focus();
  763. if (i != D.getScrollTop()) {window.scrollTo(F, i);}
  764. }, 10);
  765. } catch (E) {}
  766. }
  767. }
  768. };
  769. var p = false;
  770. if (this.editmode != "selectedrow") {p = true;}
  771. if (p) {
  772. var v = this.editmode;
  773. this.editmode = "selectedrow";
  774. }
  775. var h = false;
  776. var d = {};
  777. if (this.validationpopup) {
  778. this.validationpopup.hide();
  779. this.validationpopuparrow.hide();
  780. }
  781. for (var B = 0; B < this.columns.records.length; B++) {
  782. var e = this.columns.records[B];
  783. if (!e.editable) {continue;}
  784. if (e.hidden) {continue;}
  785. if (e.columntype == "checkbox") {continue;}
  786. if (e.createwidget) {continue;}
  787. var l = this._geteditorvalue(e);
  788. var g = function (F) {
  789. F._hidecelleditor();
  790. var E = F.getcellvalue(F.editcell.row, e.displayfield);
  791. if (e.cellendedit) {e.cellendedit(k, u, e.columntype, E, l);}
  792. F.editchar = null;
  793. var I;
  794. if (e.displayfield != e.datafield) {
  795. var i = F.getcellvalue(F.editcell.row, e.displayfield);
  796. var H = E;
  797. I = { value: H, label: i };
  798. } else {I = E;}
  799. var G = F.getrowdata(k);
  800. F._raiseEvent(18, { rowindex: k, row: G, datafield: u, displayfield: e.displayfield, oldvalue: E, value: E, columntype: e.columntype });
  801. F.editcell.editing = false;
  802. };
  803. if (o) {
  804. g(this);
  805. continue;
  806. }
  807. if (e.cellvaluechanging) {
  808. var n = this.getcellvalue(this.editcell.row, e.displayfield);
  809. var b = e.cellvaluechanging(k, u, e.columntype, n, l);
  810. if (b != undefined) {l = b;}
  811. }
  812. var u = e.datafield;
  813. if (e.validation) {
  814. var c = this.getcell(k, e.datafield);
  815. try {
  816. var w = e.validation(c, l);
  817. var r = this.gridlocalization.validationstring;
  818. if (w.message != undefined) {r = w.message;}
  819. var t = typeof w == "boolean" ? w : w.result;
  820. if (!t) {
  821. if (w.showmessage == undefined || w.showmessage == true) {this._showvalidationpopup(k, u, r);}
  822. h = true;
  823. this.editcell[e.datafield].validated = false;
  824. continue;
  825. }
  826. } catch (z) {
  827. this._showvalidationpopup(k, u, this.gridlocalization.validationstring);
  828. this.editcell[e.datafield].validated = false;
  829. h = true;
  830. continue;
  831. }
  832. }
  833. if (e.displayfield != e.datafield) {
  834. var q = this.getcellvalue(this.editcell.row, e.displayfield);
  835. var x = this.editcell.value;
  836. n = { value: x, label: q };
  837. } else {n = this.getcellvalue(this.editcell.row, e.displayfield);}
  838. d[e.datafield] = { newvalue: l, oldvalue: n };
  839. }
  840. var y = {};
  841. var s = {};
  842. if (!h) {
  843. this._hidecelleditor(false);
  844. for (var B = 0; B < this.columns.records.length; B++) {
  845. var e = this.columns.records[B];
  846. var u = e.datafield;
  847. if (e.hidden) {continue;}
  848. if (!e.editable) {continue;}
  849. var f = this.getrowdata(k);
  850. if (e.createwidget) {continue;}
  851. if (e.columntype == "checkbox") {
  852. var l = this.getcellvalue(k, e.displayfield);
  853. this._raiseEvent(18, { rowindex: k, row: f, datafield: e.datafield, displayfield: e.displayfield, oldvalue: l, value: l, columntype: e.columntype });
  854. continue;
  855. }
  856. if (!d[e.datafield]) {continue;}
  857. var l = d[e.datafield].newvalue;
  858. var n = d[e.datafield].oldvalue;
  859. if (e.cellendedit) {
  860. var A = e.cellendedit(k, u, e.columntype, n, l);
  861. if (A == false) {
  862. this._raiseEvent(18, { rowindex: k, row: f, datafield: u, displayfield: e.displayfield, oldvalue: n, value: n, columntype: e.columntype });
  863. g(this);
  864. continue;
  865. }
  866. }
  867. if (!this.source.updaterow) {this._raiseEvent(18, { rowindex: k, row: f, datafield: e.datafield, displayfield: e.displayfield, oldvalue: n, value: l, columntype: e.columntype });}
  868. y[e.datafield] = l;
  869. s[e.datafield] = n;
  870. }
  871. var j = this.getrowid(k);
  872. var f = this.getrowdata(k);
  873. a.each(y, function (i, F) {
  874. if (F && F.label != undefined) {
  875. var E = D.getcolumn(i);
  876. f[E.displayfield] = F.label;
  877. f[E.datafield] = F.value;
  878. } else {f[i] = F;}
  879. });
  880. if (!this.enablebrowserselection) {
  881. this.host.addClass("jqx-disableselect");
  882. this.content.addClass("jqx-disableselect");
  883. }
  884. a.data(document.body, "jqxgrid.edit", "");
  885. this.editcell = null;
  886. this.editchar = null;
  887. if (this.source.updaterow && !o) {
  888. var m = false;
  889. var D = this;
  890. var t = function (I) {
  891. var G = D.source.updaterow;
  892. D.source.updaterow = null;
  893. if (false == I) {
  894. a.each(s, function (i, K) {
  895. if (K && K.label != undefined) {
  896. var J = D.getcolumn(i);
  897. f[J.displayfield] = K.label;
  898. f[J.datafield] = K.value;
  899. } else {f[i] = K;}
  900. });
  901. D.updaterow(j, f);
  902. } else {D.updaterow(j, f);}
  903. for (var F = 0; F < D.columns.records.length; F++) {
  904. var H = D.columns.records[F];
  905. var E = H.datafield;
  906. D._raiseEvent(18, { rowindex: k, datafield: H.datafield, row: f, displayfield: H.displayfield, oldvalue: s[H.datafield], value: f[H.displayfield], columntype: H.columntype });
  907. }
  908. D.source.updaterow = G;
  909. };
  910. try {
  911. m = this.source.updaterow(j, f, t);
  912. if (m == undefined) {m = true;}
  913. } catch (z) {
  914. m = false;
  915. return;
  916. }
  917. } else {
  918. if (!o) {this.updaterow(j, f);}
  919. this._renderrows(this.virtualsizeinfo);
  920. }
  921. }
  922. if (p) {this.editmode = v;}
  923. return h;
  924. }, _selection: function (b) {
  925. if ("selectionStart" in b[0]) {
  926. var g = b[0];
  927. var h = g.selectionEnd - g.selectionStart;
  928. return { start: g.selectionStart, end: g.selectionEnd, length: h, text: g.value };
  929. } else {
  930. var d = document.selection.createRange();
  931. if (d == null) {return { start: 0, end: g.value.length, length: 0 };}
  932. var c = b[0].createTextRange();
  933. var f = c.duplicate();
  934. c.moveToBookmark(d.getBookmark());
  935. f.setEndPoint("EndToStart", c);
  936. var h = d.text.length;
  937. return { start: f.text.length, end: f.text.length + d.text.length, length: h, text: d.text };
  938. }
  939. }, _setSelection: function (e, b, d) {
  940. if ("selectionStart" in d[0]) {
  941. d[0].focus();
  942. d[0].setSelectionRange(e, b);
  943. } else {
  944. var c = d[0].createTextRange();
  945. c.collapse(true);
  946. c.moveEnd("character", b);
  947. c.moveStart("character", e);
  948. c.select();
  949. }
  950. }, findRecordIndex: function (g, c, b) {
  951. var b = b;
  952. if (c) {
  953. var e = b.length;
  954. for (var h = 0; h < e; h++) {
  955. var f = b[h];
  956. var d = f.label;
  957. if (g == d) {return h;}
  958. }
  959. }
  960. return -1;
  961. }, _destroyeditors: function () {
  962. var b = this;
  963. if (!this.columns.records) {return;}
  964. a.each(this.columns.records, function (f, j) {
  965. var c = a.trim(this.datafield).split(" ").join("");
  966. switch (this.columntype) {
  967. case"dropdownlist":
  968. var g = b.editors["dropdownlist_" + c];
  969. if (g) {
  970. g.jqxDropDownList("destroy");
  971. b.editors["dropdownlist_" + c] = null;
  972. }
  973. break;
  974. case"combobox":
  975. var k = b.editors["combobox_" + c];
  976. if (k) {
  977. k.jqxComboBox("destroy");
  978. b.editors["combobox_" + c] = null;
  979. }
  980. break;
  981. case"datetimeinput":
  982. var d = b.editors["datetimeinput_" + this.datafield];
  983. if (d) {
  984. d.jqxDateTimeInput("destroy");
  985. b.editors["datetimeinput_" + c] = null;
  986. }
  987. break;
  988. case"numberinput":
  989. var e = b.editors["numberinput_" + c];
  990. if (e) {
  991. e.jqxNumberInput("destroy");
  992. b.editors["numberinput_" + c] = null;
  993. }
  994. break;
  995. case"custom":
  996. case"template":
  997. if (b.destroyeditor) {
  998. if (b.editors["templateeditor_" + c]) {
  999. b.destroyeditor(b.editors["templateeditor_" + c]);
  1000. b.editors["templateeditor_" + c] = null;
  1001. }
  1002. }
  1003. if (b.destroyeditor) {
  1004. var m = b.getrows.length();
  1005. for (var l = 0; l < m; l++) {
  1006. if (b.editors["customeditor_" + c + "_" + l]) {
  1007. b.destroyeditor(b.editors["customeditor_" + c + "_" + l], l);
  1008. b.editors["customeditor_" + c + "_" + l] = null;
  1009. }
  1010. }
  1011. }
  1012. break;
  1013. case"textbox":
  1014. default:
  1015. var h = b.editors["textboxeditor_" + c];
  1016. if (h) {
  1017. b.removeHandler(h, "keydown");
  1018. b.editors["textbox_" + c] = null;
  1019. }
  1020. break;
  1021. }
  1022. });
  1023. b.editors = new Array();
  1024. }, _showcelleditor: function (r, H, o, L, x) {
  1025. if (o == undefined) {return;}
  1026. if (this.editcell == null) {return;}
  1027. if (H.columntype == "checkbox" && H.editable) {
  1028. if (this.editmode == "selectedrow") {
  1029. if (!this._checkboxCells) {this._checkboxCells = [];}
  1030. this._checkboxCells[H.datafield] = o;
  1031. }
  1032. return;
  1033. }
  1034. if (x == undefined) {x = true;}
  1035. if (this.editmode == "selectedrow") {
  1036. this.editchar = "";
  1037. x = false;
  1038. }
  1039. var F = H.datafield;
  1040. var h = a(o);
  1041. var t = this;
  1042. var d = this.editcell.editor;
  1043. var J = this.getcellvalue(r, F);
  1044. var D = this.getcelltext(r, F);
  1045. var k = this.hScrollInstance;
  1046. var u = k.value;
  1047. var j = parseInt(u);
  1048. var K = this.columns.records.indexOf(H);
  1049. this.editcell.element = o;
  1050. if (this.editcell.validated == false) {
  1051. var I = "";
  1052. if (this.validationpopup) {I = this.validationpopup.text();}
  1053. this._showvalidationpopup(r, F, I);
  1054. }
  1055. var m = function (e) {
  1056. if (t.hScrollInstance.isScrolling() || t.vScrollInstance.isScrolling()) {return;}
  1057. if (!x) {return;}
  1058. if (t.isTouchDevice()) {return;}
  1059. if (e) {e.focus();}
  1060. if (t.gridcontent[0].scrollTop != 0) {
  1061. t.scrolltop(Math.abs(t.gridcontent[0].scrollTop));
  1062. t.gridcontent[0].scrollTop = 0;
  1063. }
  1064. if (t.gridcontent[0].scrollLeft != 0) {t.gridcontent[0].scrollLeft = 0;}
  1065. };
  1066. switch (H.columntype) {
  1067. case"dropdownlist":
  1068. if (this.host.jqxDropDownList) {
  1069. o.innerHTML = "";
  1070. var E = a.trim(H.datafield).split(" ").join("");
  1071. var B = a.trim(H.displayfield).split(" ").join("");
  1072. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1073. if (B.indexOf(".") != -1) {B = B.replace(".", "");}
  1074. var l = this.editors["dropdownlist_" + E];
  1075. d = l == undefined ? a("<div style='border: none; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='dropdownlisteditor'></div>") : l;
  1076. d.css("top", a(o).parent().position().top);
  1077. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1078. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1079. if (l == undefined) {
  1080. d.prependTo(this.table);
  1081. d[0].id = "dropdownlisteditor" + this.element.id + E;
  1082. var g = this.source._source ? true : false;
  1083. var y = null;
  1084. if (!g) {y = new a.jqx.dataAdapter(this.source, { autoBind: false, uniqueDataFields: [B], async: false, autoSort: true, autoSortField: B });} else {
  1085. var q = { localdata: JSON.parse(JSON.stringify(this.source.records)), datatype: this.source.datatype, async: false };
  1086. y = new a.jqx.dataAdapter(q, { autoBind: false, async: false, uniqueDataFields: [B], autoSort: true, autoSortField: B });
  1087. }
  1088. var v = !H.createeditor ? true : false;
  1089. d.jqxDropDownList({ hint: false, enableBrowserBoundsDetection: true, keyboardSelection: false, source: y, rtl: this.rtl, autoDropDownHeight: v, theme: this.theme, width: h.width(), height: h.height(), displayMember: B, valueMember: F });
  1090. this.editors["dropdownlist_" + E] = d;
  1091. if (H.createeditor) {H.createeditor(r, J, d);}
  1092. }
  1093. if (H._requirewidthupdate) {d.jqxDropDownList({ width: h.width() });}
  1094. var c = d.jqxDropDownList("listBox").visibleItems;
  1095. if (!H.createeditor) {if (c.length < 8) {d.jqxDropDownList("autoDropDownHeight", true);} else {d.jqxDropDownList("autoDropDownHeight", false);}}
  1096. var J = this.getcellvalue(r, B);
  1097. var A = this.findRecordIndex(J, B, c);
  1098. if (L) {if (J != "") {d.jqxDropDownList("selectIndex", A, true);} else {d.jqxDropDownList("selectIndex", -1);}}
  1099. if (!this.editcell) {return;}
  1100. if (this.editcell.defaultvalue != undefined) {d.jqxDropDownList("selectIndex", this.editcell.defaultvalue, true);}
  1101. if (x) {d.jqxDropDownList("focus");}
  1102. }
  1103. break;
  1104. case"combobox":
  1105. if (this.host.jqxComboBox) {
  1106. o.innerHTML = "";
  1107. var E = a.trim(H.datafield).split(" ").join("");
  1108. var B = a.trim(H.displayfield).split(" ").join("");
  1109. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1110. if (B.indexOf(".") != -1) {B = B.replace(".", "");}
  1111. var s = this.editors["combobox_" + E];
  1112. d = s == undefined ? a("<div style='border: none; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='comboboxeditor'></div>") : s;
  1113. d.css("top", a(o).parent().position().top);
  1114. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1115. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1116. if (s == undefined) {
  1117. d.prependTo(this.table);
  1118. d[0].id = "comboboxeditor" + this.element.id + E;
  1119. var g = this.source._source ? true : false;
  1120. var y = null;
  1121. if (!g) {y = new a.jqx.dataAdapter(this.source, { autoBind: false, uniqueDataFields: [B], async: false, autoSort: true, autoSortField: B });} else {
  1122. var q = { localdata: JSON.parse(JSON.stringify(this.source.records)), datatype: this.source.datatype, async: false };
  1123. y = new a.jqx.dataAdapter(q, { autoBind: false, async: false, uniqueDataFields: [B], autoSort: true, autoSortField: B });
  1124. }
  1125. var v = !H.createeditor ? true : false;
  1126. d.jqxComboBox({ hint: false, enableBrowserBoundsDetection: true, keyboardSelection: false, source: y, rtl: this.rtl, autoDropDownHeight: v, theme: this.theme, width: h.width(), height: h.height(), displayMember: B, valueMember: F });
  1127. d.removeAttr("tabindex");
  1128. d.find("div").removeAttr("tabindex");
  1129. this.editors["combobox_" + E] = d;
  1130. if (H.createeditor) {H.createeditor(r, J, d);}
  1131. }
  1132. if (H._requirewidthupdate) {d.jqxComboBox({ width: h.width() - 2 });}
  1133. var c = d.jqxComboBox("listBox").visibleItems;
  1134. if (!H.createeditor) {if (c.length < 8) {d.jqxComboBox("autoDropDownHeight", true);} else {d.jqxComboBox("autoDropDownHeight", false);}}
  1135. var J = this.getcellvalue(r, B);
  1136. var A = this.findRecordIndex(J, B, c);
  1137. if (L) {
  1138. if (J != "") {
  1139. d.jqxComboBox("selectIndex", A, true);
  1140. d.jqxComboBox("val", J);
  1141. } else {
  1142. d.jqxComboBox("selectIndex", -1);
  1143. d.jqxComboBox("val", J);
  1144. }
  1145. }
  1146. if (!this.editcell) {return;}
  1147. if (this.editcell.defaultvalue != undefined) {d.jqxComboBox("selectIndex", this.editcell.defaultvalue, true);}
  1148. if (this.editchar && this.editchar.length > 0) {d.jqxComboBox("input").val(this.editchar);}
  1149. if (x) {
  1150. setTimeout(function () {
  1151. m(d.jqxComboBox("input"));
  1152. if (d) {
  1153. d.jqxComboBox("_setSelection", 0, 0);
  1154. if (t.editchar) {
  1155. d.jqxComboBox("_setSelection", 1, 1);
  1156. t.editchar = null;
  1157. } else {
  1158. if (d.jqxComboBox("input")) {
  1159. var e = d.jqxComboBox("input").val();
  1160. d.jqxComboBox("_setSelection", 0, e.length);
  1161. }
  1162. }
  1163. }
  1164. }, 10);
  1165. }
  1166. }
  1167. break;
  1168. case"datetimeinput":
  1169. if (this.host.jqxDateTimeInput) {
  1170. o.innerHTML = "";
  1171. var E = a.trim(H.datafield).split(" ").join("");
  1172. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1173. var w = this.editors["datetimeinput_" + E];
  1174. d = w == undefined ? a("<div style='border: none; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='datetimeeditor'></div>") : w;
  1175. d.show();
  1176. d.css("top", a(o).parent().position().top);
  1177. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1178. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1179. if (w == undefined) {
  1180. d.prependTo(this.table);
  1181. d[0].id = "datetimeeditor" + this.element.id + E;
  1182. var G = { calendar: this.gridlocalization };
  1183. d.jqxDateTimeInput({ hint: false, firstDayOfWeek: this.gridlocalization.firstDay, enableBrowserBoundsDetection: true, localization: G, _editor: true, theme: this.theme, rtl: this.rtl, width: h.width(), height: h.height(), formatString: H.cellsformat });
  1184. this.editors["datetimeinput_" + E] = d;
  1185. if (H.createeditor) {H.createeditor(r, J, d);}
  1186. }
  1187. if (H._requirewidthupdate) {d.jqxDateTimeInput({ width: h.width() });}
  1188. if (L) {
  1189. if (J != "" && J != null) {
  1190. var M = new Date(J);
  1191. if (M == "Invalid Date") {if (this.source.getvaluebytype) {M = this.source.getvaluebytype(J, { name: H.datafield, type: "date" });}}
  1192. d.jqxDateTimeInput("setDate", M);
  1193. } else {d.jqxDateTimeInput("setDate", null);}
  1194. if (this.editcell.defaultvalue != undefined) {d.jqxDateTimeInput("setDate", this.editcell.defaultvalue);}
  1195. }
  1196. if (x) {
  1197. var N = this.editEvent;
  1198. setTimeout(function () {
  1199. m(d.jqxDateTimeInput("dateTimeInput"));
  1200. setTimeout(function () {
  1201. d.jqxDateTimeInput("_selectGroup", 0);
  1202. if (t.editchar && t.editchar.length > 0) {
  1203. var R = parseInt(t.editchar);
  1204. if (!isNaN(R)) {
  1205. if (N) {
  1206. var e = N.charCode ? N.charCode : N.keyCode ? N.keyCode : 0;
  1207. d.jqxDateTimeInput("_handleKeyPress", N, e);
  1208. }
  1209. }
  1210. }
  1211. }, 25);
  1212. }, 10);
  1213. }
  1214. }
  1215. break;
  1216. case"numberinput":
  1217. if (this.host.jqxNumberInput) {
  1218. o.innerHTML = "";
  1219. var E = a.trim(H.datafield).split(" ").join("");
  1220. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1221. var P = this.editors["numberinput_" + E];
  1222. d = P == undefined ? a("<div style='border:none; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; z-index: 799; top: 0px; left: 0px; position: absolute;' id='numbereditor'></div>") : P;
  1223. d.show();
  1224. d.css("top", a(o).parent().position().top);
  1225. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1226. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1227. if (P == undefined) {
  1228. d.prependTo(this.table);
  1229. d[0].id = "numbereditor" + this.element.id + E;
  1230. var n = "";
  1231. var z = "left";
  1232. var O = 2;
  1233. if (H.cellsformat) {
  1234. if (H.cellsformat.indexOf("c") != -1) {
  1235. n = this.gridlocalization.currencysymbol;
  1236. z = this.gridlocalization.currencysymbolposition;
  1237. if (z == "before") {z = "left";} else {z = "right";}
  1238. if (H.cellsformat.length > 1) {O = parseInt(H.cellsformat.substring(1), 10);}
  1239. } else {
  1240. if (H.cellsformat.indexOf("p") != -1) {
  1241. n = this.gridlocalization.percentsymbol;
  1242. z = "right";
  1243. if (H.cellsformat.length > 1) {O = parseInt(H.cellsformat.substring(1), 10);}
  1244. }
  1245. }
  1246. } else {O = 0;}
  1247. d.jqxNumberInput({ decimalSeparator: this.gridlocalization.decimalseparator, decimalDigits: O, inputMode: "simple", theme: this.theme, rtl: this.rtl, width: h.width(), height: h.height(), spinButtons: true, symbol: n, symbolPosition: z });
  1248. this.editors["numberinput_" + E] = d;
  1249. if (H.createeditor) {H.createeditor(r, J, d);}
  1250. }
  1251. if (H._requirewidthupdate) {d.jqxNumberInput({ width: h.width() });}
  1252. if (L) {
  1253. if (J != "" && J != null) {
  1254. var Q = J;
  1255. d.jqxNumberInput("setDecimal", Q);
  1256. } else {d.jqxNumberInput("setDecimal", 0);}
  1257. if (this.editcell.defaultvalue != undefined) {d.jqxNumberInput("setDecimal", this.editcell.defaultvalue);}
  1258. if (this.editchar && this.editchar.length > 0) {
  1259. var p = parseInt(this.editchar);
  1260. if (!isNaN(p)) {d.jqxNumberInput("setDecimal", p);}
  1261. }
  1262. if (x) {
  1263. setTimeout(function () {
  1264. m(d.jqxNumberInput("numberInput"));
  1265. d.jqxNumberInput("_setSelectionStart", 0);
  1266. if (t.editchar) {
  1267. if (H.cellsformat.length > 0 && H.cellsformat.indexOf("c") >= 0) {d.jqxNumberInput("_setSelectionStart", 2);} else {d.jqxNumberInput("_setSelectionStart", 1);}
  1268. t.editchar = null;
  1269. } else {
  1270. var e = d.jqxNumberInput("spinButtons");
  1271. if (e) {
  1272. var R = d.jqxNumberInput("numberInput").val();
  1273. t._setSelection(d.jqxNumberInput("numberInput")[0], R.length, R.length);
  1274. } else {
  1275. var R = d.jqxNumberInput("numberInput").val();
  1276. t._setSelection(d.jqxNumberInput("numberInput")[0], 0, R.length);
  1277. }
  1278. d.jqxNumberInput("selectAll");
  1279. }
  1280. }, 10);
  1281. }
  1282. }
  1283. }
  1284. break;
  1285. case"custom":
  1286. o.innerHTML = "";
  1287. var E = a.trim(H.datafield).split(" ").join("");
  1288. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1289. var C = this.editors["customeditor_" + E + "_" + r];
  1290. d = C == undefined ? 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>") : C;
  1291. d.show();
  1292. d.css("top", a(o).parent().position().top);
  1293. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1294. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1295. if (C == undefined) {
  1296. d.prependTo(this.table);
  1297. d[0].id = "customeditor" + this.element.id + E + "_" + r;
  1298. this.editors["customeditor_" + E + "_" + r] = d;
  1299. var b = h.width() - 1;
  1300. var f = h.height() - 1;
  1301. d.width(b);
  1302. d.height(f);
  1303. if (H.createeditor) {H.createeditor(r, J, d, D, b, f, this.editchar);}
  1304. }
  1305. if (H._requirewidthupdate) {d.width(h.width());}
  1306. break;
  1307. case"template":
  1308. o.innerHTML = "";
  1309. var E = a.trim(H.datafield).split(" ").join("");
  1310. if (E.indexOf(".") != -1) {E = E.replace(".", "");}
  1311. var i = this.editors["templateeditor_" + E];
  1312. d = i == undefined ? 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>") : i;
  1313. d.show();
  1314. d.css("top", a(o).parent().position().top);
  1315. if (this.oldhscroll) {d.css("left", -j + parseInt(a(o).position().left));} else {d.css("left", parseInt(a(o).position().left));}
  1316. if (H.pinned) {d.css("left", j + parseInt(a(o).position().left));}
  1317. if (i == undefined) {
  1318. d.prependTo(this.table);
  1319. d[0].id = "templateeditor" + this.element.id + E;
  1320. this.editors["templateeditor_" + E] = d;
  1321. var b = h.width() - 1;
  1322. var f = h.height() - 1;
  1323. d.width(b);
  1324. d.height(f);
  1325. if (H.createeditor) {H.createeditor(r, J, d, D, b, f, this.editchar);}
  1326. }
  1327. if (H._requirewidthupdate) {d.width(h.width());}
  1328. break;
  1329. case"textbox":
  1330. default:
  1331. o.innerHTML = "";
  1332. d = this.editors["textboxeditor_" + H.datafield] || a("<input autocomplete='off' style='padding-left: 4px; padding-right:4px; border: none; border-color: transparent;' autocorrect='off' autocapitalize='off' spellcheck='false' type='textbox' id='textboxeditor'/>");
  1333. d[0].id = "textboxeditor" + this.element.id + H.datafield;
  1334. d.appendTo(h);
  1335. if (this.rtl) {d.css("direction", "rtl");}
  1336. if (L || d[0].className == "") {
  1337. d.addClass(this.toThemeProperty("jqx-input"));
  1338. d.addClass(this.toThemeProperty("jqx-widget-content"));
  1339. if (this.editchar && this.editchar.length > 0) {d.val(this.editchar);} else {
  1340. if (H.cellsformat != "") {J = this.getcelltext(r, F);}
  1341. if (J == undefined) {J = "";}
  1342. d.val(J);
  1343. }
  1344. if (this.editcell.defaultvalue != undefined) {d.val(this.editcell.defaultvalue);}
  1345. d.width(h.width() + 1);
  1346. d.height(h.height() + 1);
  1347. if (H.createeditor) {H.createeditor(r, J, d);}
  1348. if (H.cellsformat != "") {
  1349. if (H.cellsformat.indexOf("p") != -1 || H.cellsformat.indexOf("c") != -1 || H.cellsformat.indexOf("n") != -1 || H.cellsformat.indexOf("f") != -1) {
  1350. if (!this.editors["textboxeditor_" + H.datafield]) {
  1351. d.keydown(function (R) {
  1352. var X = R.charCode ? R.charCode : R.keyCode ? R.keyCode : 0;
  1353. var U = String.fromCharCode(X);
  1354. var V = parseInt(U);
  1355. if (isNaN(V)) {return true;}
  1356. if (t._selection(d).length > 0) {return true;}
  1357. var T = "";
  1358. var S = d.val();
  1359. if (H.cellsformat.length > 1) {
  1360. var W = parseInt(H.cellsformat.substring(1));
  1361. if (isNaN(W)) {W = 0;}
  1362. } else {var W = 0;}
  1363. if (W > 0) {if (S.indexOf(t.gridlocalization.decimalseparator) != -1) {if (t._selection(d).start > S.indexOf(t.gridlocalization.decimalseparator)) {return true;}}}
  1364. for (var Y = 0; Y < S.length - W; Y++) {
  1365. var e = S.substring(Y, Y + 1);
  1366. if (e.match(/^[0-9]+$/) != null) {T += e;}
  1367. }
  1368. if (T.length >= 11) {return false;}
  1369. });
  1370. }
  1371. }
  1372. }
  1373. }
  1374. this.editors["textboxeditor_" + H.datafield] = d;
  1375. if (L) {
  1376. if (x) {
  1377. setTimeout(function () {
  1378. m(d);
  1379. if (t.editchar) {
  1380. t._setSelection(d[0], 1, 1);
  1381. t.editchar = null;
  1382. } else {t._setSelection(d[0], 0, d.val().length);}
  1383. }, 25);
  1384. }
  1385. }
  1386. break;
  1387. }
  1388. if (d) {
  1389. d.addClass("jqx-grid-cell-edit");
  1390. d[0].style.zIndex = 1 + parseInt(o.style.zIndex);
  1391. if (a.jqx.browser.msie && a.jqx.browser.version < 8) {d[0].style.zIndex = 1 + this.columns.records.length + o.style.zIndex;}
  1392. d.css("display", "block");
  1393. this.editcell.editor = d;
  1394. if (!this.editcell[F]) {
  1395. this.editcell[F] = {};
  1396. this.editcell[F].editor = d;
  1397. } else {this.editcell[F].editor = d;}
  1398. }
  1399. if (L) {if (H.initeditor) {H.initeditor(r, J, d, D, this.editchar);}}
  1400. if (t.isTouchDevice()) {return;}
  1401. setTimeout(function () {
  1402. if (t.content) {
  1403. t.content[0].scrollTop = 0;
  1404. t.content[0].scrollLeft = 0;
  1405. }
  1406. if (t.gridcontent) {
  1407. t.gridcontent[0].scrollLeft = 0;
  1408. t.gridcontent[0].scrollTop = 0;
  1409. }
  1410. }, 10);
  1411. }, _setSelection: function (d, g, b) {
  1412. try {
  1413. if ("selectionStart" in d) {d.setSelectionRange(g, b);} else {
  1414. var c = d.createTextRange();
  1415. c.collapse(true);
  1416. c.moveEnd("character", b);
  1417. c.moveStart("character", g);
  1418. c.select();
  1419. }
  1420. } catch (e) {var f = e;}
  1421. }, _hideeditors: function () {
  1422. if (this.editcells != null) {
  1423. var b = this;
  1424. for (var c in this.editcells) {
  1425. b.editcell = b.editcells[c];
  1426. b._hidecelleditor();
  1427. }
  1428. }
  1429. }, _hidecelleditor: function (b) {
  1430. if (!this.editcell) {return;}
  1431. if (this.editmode === "selectedrow") {
  1432. for (var c = 0; c < this.columns.records.length; c++) {
  1433. var e = this.columns.records[c];
  1434. if (this.editcell[e.datafield] && this.editcell[e.datafield].editor) {
  1435. this.editcell[e.datafield].editor.hide();
  1436. var d = this.editcell[e.datafield].editor;
  1437. switch (e.columntype) {
  1438. case"dropdownlist":
  1439. d.jqxDropDownList({ closeDelay: 0 });
  1440. d.jqxDropDownList("hideListBox");
  1441. d.jqxDropDownList({ closeDelay: 300 });
  1442. break;
  1443. case"combobox":
  1444. d.jqxComboBox({ closeDelay: 0 });
  1445. d.jqxComboBox("hideListBox");
  1446. d.jqxComboBox({ closeDelay: 300 });
  1447. break;
  1448. case"datetimeinput":
  1449. if (d.jqxDateTimeInput("isOpened")) {
  1450. d.jqxDateTimeInput({ closeDelay: 0 });
  1451. d.jqxDateTimeInput("hideCalendar");
  1452. d.jqxDateTimeInput({ closeDelay: 300 });
  1453. }
  1454. break;
  1455. }
  1456. }
  1457. }
  1458. if (this.validationpopup) {
  1459. this.validationpopup.hide();
  1460. this.validationpopuparrow.hide();
  1461. }
  1462. return;
  1463. }
  1464. if (this.editcell.columntype == "checkbox") {return;}
  1465. if (this.editcell.editor) {
  1466. this.editcell.editor.hide();
  1467. switch (this.editcell.columntype) {
  1468. case"dropdownlist":
  1469. this.editcell.editor.jqxDropDownList({ closeDelay: 0 });
  1470. this.editcell.editor.jqxDropDownList("hideListBox");
  1471. this.editcell.editor.jqxDropDownList({ closeDelay: 300 });
  1472. break;
  1473. case"combobox":
  1474. this.editcell.editor.jqxComboBox({ closeDelay: 0 });
  1475. this.editcell.editor.jqxComboBox("hideListBox");
  1476. this.editcell.editor.jqxComboBox({ closeDelay: 300 });
  1477. break;
  1478. case"datetimeinput":
  1479. var f = this.editcell.editor;
  1480. if (f.jqxDateTimeInput("isOpened")) {
  1481. f.jqxDateTimeInput({ closeDelay: 0 });
  1482. f.jqxDateTimeInput("hideCalendar");
  1483. f.jqxDateTimeInput({ closeDelay: 300 });
  1484. }
  1485. break;
  1486. }
  1487. }
  1488. if (this.validationpopup) {
  1489. this.validationpopup.hide();
  1490. this.validationpopuparrow.hide();
  1491. }
  1492. if (!this.isNestedGrid) {if (b != false) {this.element.focus();}}
  1493. }, _geteditorvalue: function (h) {
  1494. var o = new String();
  1495. if (!this.editcell) {return null;}
  1496. var l = this.editcell.editor;
  1497. if (this.editmode == "selectedrow") {if (this.editcell[h.datafield]) {var l = this.editcell[h.datafield].editor;}}
  1498. if (l) {
  1499. switch (h.columntype) {
  1500. case"textbox":
  1501. default:
  1502. o = l.val();
  1503. if (h.cellsformat != "") {
  1504. var n = "string";
  1505. var e = this.source.datafields || ((this.source._source) ? this.source._source.datafields : null);
  1506. if (e) {
  1507. var p = "";
  1508. a.each(e, function () {
  1509. if (this.name == h.displayfield) {
  1510. if (this.type) {p = this.type;}
  1511. return false;
  1512. }
  1513. });
  1514. if (p) {n = p;}
  1515. }
  1516. var i = n === "number" || n === "float" || n === "int" || n === "integer";
  1517. var f = n === "date" || n === "time";
  1518. if (i || (n === "string" && (h.cellsformat.indexOf("p") != -1 || h.cellsformat.indexOf("c") != -1 || h.cellsformat.indexOf("n") != -1 || h.cellsformat.indexOf("f") != -1))) {
  1519. if (o === "" && h.nullable) {return "";}
  1520. if (o.indexOf && o.indexOf(this.gridlocalization.currencysymbol) > -1) {o = o.replace(this.gridlocalization.currencysymbol, "");}
  1521. var m = function (w, u, v) {
  1522. var s = w;
  1523. if (u == v) {return w;}
  1524. var t = s.indexOf(u);
  1525. while (t != -1) {
  1526. s = s.replace(u, v);
  1527. t = s.indexOf(u);
  1528. }
  1529. return s;
  1530. };
  1531. var k = o;
  1532. k = new Number(k);
  1533. if (!isNaN(k)) {return k;}
  1534. o = m(o, this.gridlocalization.thousandsseparator, "");
  1535. o = o.replace(this.gridlocalization.decimalseparator, ".");
  1536. if (o.indexOf(this.gridlocalization.percentsymbol) > -1) {o = o.replace(this.gridlocalization.percentsymbol, "");}
  1537. var d = "";
  1538. for (var r = 0; r < o.length; r++) {
  1539. var b = o.substring(r, r + 1);
  1540. if (b === "-") {d += "-";}
  1541. if (b === ".") {d += ".";}
  1542. if (b.match(/^[0-9]+$/) != null) {d += b;}
  1543. }
  1544. o = d;
  1545. o = o.replace(/ /g, "");
  1546. o = new Number(o);
  1547. if (isNaN(o)) {o = "";}
  1548. }
  1549. if (f || (n === "string" && (h.cellsformat.indexOf("H") != -1 || h.cellsformat.indexOf("m") != -1 || h.cellsformat.indexOf("M") != -1 || h.cellsformat.indexOf("y") != -1 || h.cellsformat.indexOf("h") != -1 || h.cellsformat.indexOf("d") != -1))) {
  1550. if (o === "" && h.nullable) {return "";}
  1551. var c = o;
  1552. if (a.jqx.dataFormat) {o = a.jqx.dataFormat.tryparsedate(c, this.gridlocalization);}
  1553. if (o == "Invalid Date" || o == null) {o = "";}
  1554. }
  1555. }
  1556. if (h.displayfield != h.datafield) {o = { label: o, value: o };}
  1557. break;
  1558. case"checkbox":
  1559. if (l.jqxCheckBox) {o = l.jqxCheckBox("checked");}
  1560. break;
  1561. case"datetimeinput":
  1562. if (l.jqxDateTimeInput) {
  1563. l.jqxDateTimeInput({ isEditing: false });
  1564. if (l.jqxDateTimeInput("container").css("display") !== "none") {l.jqxDateTimeInput("close");}
  1565. l.jqxDateTimeInput("_validateValue");
  1566. o = l.jqxDateTimeInput("getDate");
  1567. if (o == null) {return null;}
  1568. o = new Date(o.toString());
  1569. if (h.displayfield != h.datafield) {o = { label: o, value: o };}
  1570. }
  1571. break;
  1572. case"dropdownlist":
  1573. if (l.jqxDropDownList) {
  1574. var g = l.jqxDropDownList("selectedIndex");
  1575. var q = l.jqxDropDownList("listBox").getVisibleItem(g);
  1576. if (h.displayfield != h.datafield) {if (q) {o = { label: q.label, value: q.value };} else {o = "";}} else {if (q) {o = q.label;} else {o = "";}}
  1577. if (o == null) {o = "";}
  1578. }
  1579. break;
  1580. case"combobox":
  1581. if (l.jqxComboBox) {
  1582. o = l.jqxComboBox("val");
  1583. if (h.displayfield != h.datafield) {
  1584. var q = l.jqxComboBox("getSelectedItem");
  1585. if (q != null) {o = { label: q.label, value: q.value };}
  1586. }
  1587. if (o == null) {o = "";}
  1588. }
  1589. break;
  1590. case"numberinput":
  1591. if (l.jqxNumberInput) {
  1592. if (this.touchdevice) {l.jqxNumberInput("_doTouchHandling");}
  1593. var j = l.jqxNumberInput("getDecimal");
  1594. o = new Number(j);
  1595. o = parseFloat(o);
  1596. if (isNaN(o)) {o = 0;}
  1597. if (j === null) {o = null;}
  1598. if (h.displayfield != h.datafield) {o = { label: o, value: o };}
  1599. }
  1600. break;
  1601. }
  1602. if (h.geteditorvalue) {if (this.editmode == "selectedrow") {o = h.geteditorvalue(this.editcell.row, this.getcellvalue(this.editcell.row, h.datafield), l);} else {o = h.geteditorvalue(this.editcell.row, this.editcell.value, l);}}
  1603. }
  1604. return o;
  1605. }, hidevalidationpopups: function () {
  1606. if (this.popups) {
  1607. a.each(this.popups, function () {
  1608. this.validation.remove();
  1609. this.validationrow.remove();
  1610. });
  1611. this.popups = new Array();
  1612. }
  1613. if (this.validationpopup) {
  1614. this.validationpopuparrow.hide();
  1615. this.validationpopup.hide();
  1616. }
  1617. }, showvalidationpopup: function (f, j, h) {
  1618. if (h == undefined) {var h = this.gridlocalization.validationstring;}
  1619. var g = a("<div style='z-index: 99999; top: 0px; left: 0px; position: absolute;'></div>");
  1620. var r = a("<div style='width: 20px; height: 20px; z-index: 999999; top: 0px; left: 0px; position: absolute;'></div>");
  1621. g.html(h);
  1622. r.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1623. g.addClass(this.toThemeProperty("jqx-grid-validation"));
  1624. g.addClass(this.toThemeProperty("jqx-rc-all"));
  1625. g.prependTo(this.table);
  1626. r.prependTo(this.table);
  1627. var l = this.hScrollInstance;
  1628. var n = l.value;
  1629. var d = parseInt(n);
  1630. var b = this.getcolumn(j).uielement;
  1631. var p = null;
  1632. for (var o = 0; o < this.hittestinfo.length; o++) {if (f === this.hittestinfo[o].row.visibleindex) {p = this.hittestinfo[o];}}
  1633. if (!p) {
  1634. this.ensurerowvisible(f);
  1635. var s = this;
  1636. g.remove();
  1637. r.remove();
  1638. setTimeout(function () {
  1639. var v = null;
  1640. for (var u = 0; u < s.hittestinfo.length; u++) {if (f === s.hittestinfo[u].row.visibleindex) {v = s.hittestinfo[u];}}
  1641. if (v) {s.showvalidationpopup(f, j, h);}
  1642. }, 25);
  1643. return;
  1644. }
  1645. var c = a(p.visualrow);
  1646. g.css("top", parseInt(c.position().top) + 30 + "px");
  1647. var k = parseInt(g.css("top"));
  1648. r.css("top", k - 12);
  1649. r.removeClass();
  1650. r.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1651. var q = false;
  1652. if (k >= this._gettableheight() - this.rowsheight) {
  1653. r.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1654. r.addClass(this.toThemeProperty("jqx-grid-validation-arrow-down"));
  1655. k = parseInt(c.position().top) - this.rowsheight;
  1656. if (k < 0) {
  1657. k = 0;
  1658. this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-down"));
  1659. q = true;
  1660. }
  1661. g.css("top", k + "px");
  1662. r.css("top", k + g.outerHeight() - 9);
  1663. }
  1664. var t = -d + parseInt(a(b).position().left);
  1665. if (b[0].offsetHeight === 0) {t = -d + parseInt(b[0].style.left);}
  1666. r.css("left", d + t + 30);
  1667. var m = g.width();
  1668. if (m + t > this.host.width() - 20) {
  1669. var e = m + t - this.host.width() + 40;
  1670. t -= e;
  1671. }
  1672. if (!q) {g.css("left", d + t);} else {g.css("left", d + parseInt(a(b).position().left) - g.outerWidth());}
  1673. g.show();
  1674. r.show();
  1675. if (!this.popups) {this.popups = new Array();}
  1676. this.popups[this.popups.length] = { validation: g, validationrow: r };
  1677. }, _showvalidationpopup: function (p, e, q) {
  1678. var c = this.editcell;
  1679. var k = this.editcell.editor;
  1680. if (this.editmode == "selectedrow") {
  1681. var c = this.editcell[e];
  1682. if (c && c.editor) {
  1683. k = c.editor;
  1684. c.element = k;
  1685. }
  1686. }
  1687. if (!k) {return;}
  1688. if (this.validationpopup && a.jqx.isHidden(this.validationpopup)) {
  1689. if (this.validationpopup.remove) {
  1690. this.validationpopup.remove();
  1691. this.validationpopuparrow.remove();
  1692. }
  1693. this.validationpopup = null;
  1694. this.validationpopuparrow = null;
  1695. if (e === undefined && q === undefined && this.editors && this.editors.length === 0) {return;}
  1696. }
  1697. if (!this.validationpopup) {
  1698. var n = a("<div style='z-index: 99999; top: 0px; left: 0px; position: absolute;'></div>");
  1699. var m = a("<div style='width: 20px; height: 20px; z-index: 999999; top: 0px; left: 0px; position: absolute;'></div>");
  1700. n.html(q);
  1701. m.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1702. n.addClass(this.toThemeProperty("jqx-grid-validation"));
  1703. n.addClass(this.toThemeProperty("jqx-rc-all"));
  1704. n.prependTo(this.table);
  1705. m.prependTo(this.table);
  1706. this.validationpopup = n;
  1707. this.validationpopuparrow = m;
  1708. } else {this.validationpopup.html(q);}
  1709. var h = this.hScrollInstance;
  1710. var j = h.value;
  1711. var g = parseInt(j);
  1712. if (this.editmode == "selectedrow") {if (this.visiblerows && this.visiblerows[this.editcell.visiblerowindex]) {this.validationpopup.css("top", this.visiblerows[this.editcell.visiblerowindex].top + (this.rowsheight + 5) + "px");} else {this.validationpopup.css("top", parseInt(a(c.editor).position().top) + (this.rowsheight + 5) + "px");}} else {this.validationpopup.css("top", parseInt(a(c.element).parent().position().top) + (this.rowsheight + 5) + "px");}
  1713. var b = parseInt(this.validationpopup.css("top"));
  1714. this.validationpopuparrow.css("top", b - 11);
  1715. this.validationpopuparrow.removeClass();
  1716. this.validationpopuparrow.addClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1717. var o = this._gettableheight();
  1718. var f = false;
  1719. if (b >= o) {
  1720. this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-up"));
  1721. this.validationpopuparrow.addClass(this.toThemeProperty("jqx-grid-validation-arrow-down"));
  1722. b = parseInt(a(c.element).parent().position().top) - this.rowsheight - 5;
  1723. if (this.editmode == "selectedrow") {if (this.visiblerows && this.visiblerows[this.editcell.visiblerowindex]) {b = this.visiblerows[this.editcell.visiblerowindex].top - this.rowsheight - 5;} else {b = parseInt(a(c.editor).position().top) - this.rowsheight - 5;}}
  1724. if (b < 0) {
  1725. b = 0;
  1726. this.validationpopuparrow.removeClass(this.toThemeProperty("jqx-grid-validation-arrow-down"));
  1727. f = true;
  1728. }
  1729. this.validationpopup.css("top", b + "px");
  1730. this.validationpopuparrow.css("top", b + this.validationpopup.outerHeight() - 9);
  1731. }
  1732. var l = -g + parseInt(a(c.element).position().left);
  1733. this.validationpopuparrow.css("left", g + l + 30);
  1734. var d = this.validationpopup.width();
  1735. if (d + l > this.host.width() - 20) {
  1736. var i = d + l - this.host.width() + 40;
  1737. l -= i;
  1738. }
  1739. if (!f) {this.validationpopup.css("left", g + l);} else {this.validationpopup.css("left", g + parseInt(a(c.element).position().left) - this.validationpopup.outerWidth());}
  1740. if (this.editcell.editor.css("display") == "none") {
  1741. this.validationpopup.hide();
  1742. this.validationpopuparrow.hide();
  1743. } else {
  1744. this.validationpopup.show();
  1745. this.validationpopuparrow.show();
  1746. }
  1747. }
  1748. });
  1749. })(jqxBaseFramework);