e3b29ca439d732fdf8f37e0c2329be7726cce84f.svn-base 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.grid.GridView = function(A) {
  7. Ext.grid.GridView.superclass.constructor.call(this);
  8. this.el = null;
  9. Ext.apply(this, A)
  10. };
  11. Ext.extend(Ext.grid.GridView, Ext.grid.AbstractGridView, {
  12. rowClass : "x-grid-row",
  13. cellClass : "x-grid-col",
  14. tdClass : "x-grid-td",
  15. hdClass : "x-grid-hd",
  16. splitClass : "x-grid-split",
  17. sortClasses : ["sort-asc", "sort-desc"],
  18. enableMoveAnim : false,
  19. hlColor : "C3DAF9",
  20. dh : Ext.DomHelper,
  21. fly : Ext.Element.fly,
  22. css : Ext.util.CSS,
  23. borderWidth : 1,
  24. splitOffset : 3,
  25. scrollIncrement : 22,
  26. cellRE : /(?:.*?)x-grid-(?:hd|cell|csplit)-(?:[\d]+)-([\d]+)(?:.*?)/,
  27. findRE : /\s?(?:x-grid-hd|x-grid-col|x-grid-csplit)\s/,
  28. getEditorParent : function(A) {
  29. return A.parentEl || document.body
  30. },
  31. bind : function(B, A) {
  32. if (this.ds) {
  33. this.ds.un("load", this.onLoad, this);
  34. this.ds.un("datachanged", this.onDataChange);
  35. this.ds.un("add", this.onAdd);
  36. this.ds.un("remove", this.onRemove);
  37. this.ds.un("update", this.onUpdate);
  38. this.ds.un("clear", this.onClear)
  39. }
  40. if (B) {
  41. B.on("load", this.onLoad, this);
  42. B.on("datachanged", this.onDataChange, this);
  43. B.on("add", this.onAdd, this);
  44. B.on("remove", this.onRemove, this);
  45. B.on("update", this.onUpdate, this);
  46. B.on("clear", this.onClear, this)
  47. }
  48. this.ds = B;
  49. if (this.cm) {
  50. this.cm.un("widthchange", this.onColWidthChange, this);
  51. this.cm.un("headerchange", this.onHeaderChange, this);
  52. this.cm.un("hiddenchange", this.onHiddenChange, this);
  53. this.cm.un("columnmoved", this.onColumnMove, this);
  54. this.cm.un("columnlockchange", this.onColumnLock, this)
  55. }
  56. if (A) {
  57. this.generateRules(A);
  58. A.on("widthchange", this.onColWidthChange, this);
  59. A.on("headerchange", this.onHeaderChange, this);
  60. A.on("hiddenchange", this.onHiddenChange, this);
  61. A.on("columnmoved", this.onColumnMove, this);
  62. A.on("columnlockchange", this.onColumnLock, this)
  63. }
  64. this.cm = A
  65. },
  66. init : function(A) {
  67. Ext.grid.GridView.superclass.init.call(this, A);
  68. this.bind(A.dataSource, A.colModel);
  69. A.on("headerclick", this.handleHeaderClick, this);
  70. if (A.trackMouseOver) {
  71. A.on("mouseover", this.onRowOver, this);
  72. A.on("mouseout", this.onRowOut, this)
  73. }
  74. A.cancelTextSelection = function() {
  75. };
  76. this.gridId = A.id;
  77. var B = this.templates || {};
  78. if (!B.master) {
  79. B.master = new Ext.Template(
  80. "<div class=\"x-grid\" hidefocus=\"true\">",
  81. "<div class=\"x-grid-topbar\"></div>",
  82. "<div class=\"x-grid-scroller\"><div></div></div>",
  83. "<div class=\"x-grid-locked\">",
  84. "<div class=\"x-grid-header\">{lockedHeader}</div>",
  85. "<div class=\"x-grid-body\">{lockedBody}</div>",
  86. "</div>",
  87. "<div class=\"x-grid-viewport\">",
  88. "<div class=\"x-grid-header\">{header}</div>",
  89. "<div class=\"x-grid-body\">{body}</div>",
  90. "</div>",
  91. "<div class=\"x-grid-bottombar\"></div>",
  92. "<a href=\"#\" class=\"x-grid-focus\" tabIndex=\"-1\"></a>",
  93. "<div class=\"x-grid-resize-proxy\">&#160;</div>", "</div>");
  94. B.master.disableformats = true
  95. }
  96. if (!B.header) {
  97. B.header = new Ext.Template(
  98. "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">",
  99. "<tbody><tr class=\"x-grid-hd-row\">{cells}</tr></tbody>",
  100. "</table>{splits}");
  101. B.header.disableformats = true
  102. }
  103. B.header.compile();
  104. if (!B.hcell) {
  105. B.hcell = new Ext.Template(
  106. "<td class=\"x-grid-hd x-grid-td-{id} {cellId}\"><div title=\"{title}\" class=\"x-grid-hd-inner x-grid-hd-{id}\">",
  107. "<div class=\"x-grid-hd-text\" unselectable=\"on\">{value}<img class=\"x-grid-sort-icon\" src=\"",
  108. Ext.BLANK_IMAGE_URL, "\" /></div>", "</div></td>");
  109. B.hcell.disableFormats = true
  110. }
  111. B.hcell.compile();
  112. if (!B.hsplit) {
  113. B.hsplit = new Ext.Template("<div class=\"x-grid-split {splitId} x-grid-split-{id}\" style=\"{style}\" unselectable=\"on\">&#160;</div>");
  114. B.hsplit.disableFormats = true
  115. }
  116. B.hsplit.compile();
  117. if (!B.body) {
  118. B.body = new Ext.Template(
  119. "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">",
  120. "<tbody>{rows}</tbody>", "</table>");
  121. B.body.disableFormats = true
  122. }
  123. B.body.compile();
  124. if (!B.row) {
  125. B.row = new Ext.Template("<tr class=\"x-grid-row {alt}\">{cells}</tr>");
  126. B.row.disableFormats = true
  127. }
  128. B.row.compile();
  129. if (!B.cell) {
  130. B.cell = new Ext.Template(
  131. "<td class=\"x-grid-col x-grid-td-{id} {cellId} {css}\" tabIndex=\"0\">",
  132. "<div class=\"x-grid-col-{id} x-grid-cell-inner\"><div class=\"x-grid-cell-text\" unselectable=\"on\" {attr}>{value}</div></div>",
  133. "</td>");
  134. B.cell.disableFormats = true
  135. }
  136. B.cell.compile();
  137. this.templates = B
  138. },
  139. onColWidthChange : function() {
  140. this.updateColumns.apply(this, arguments)
  141. },
  142. onHeaderChange : function() {
  143. this.updateHeaders.apply(this, arguments)
  144. },
  145. onHiddenChange : function() {
  146. this.handleHiddenChange.apply(this, arguments)
  147. },
  148. onColumnMove : function() {
  149. this.handleColumnMove.apply(this, arguments)
  150. },
  151. onColumnLock : function() {
  152. this.handleLockChange.apply(this, arguments)
  153. },
  154. onDataChange : function() {
  155. this.refresh();
  156. this.updateHeaderSortState()
  157. },
  158. onClear : function() {
  159. this.refresh()
  160. },
  161. onUpdate : function(B, A) {
  162. this.refreshRow(A)
  163. },
  164. refreshRow : function(A) {
  165. var C = this.ds, B;
  166. if (typeof A == "number") {
  167. B = A;
  168. A = C.getAt(B)
  169. } else {
  170. B = C.indexOf(A)
  171. }
  172. this.insertRows(C, B, B, true);
  173. this.onRemove(C, A, B + 1, true);
  174. this.syncRowHeights(B, B);
  175. this.layout();
  176. this.fireEvent("rowupdated", this, B, A)
  177. },
  178. onAdd : function(C, A, B) {
  179. this.insertRows(C, B, B + (A.length - 1))
  180. },
  181. onRemove : function(F, B, D, E) {
  182. if (E !== true) {
  183. this.fireEvent("beforerowremoved", this, D, B)
  184. }
  185. var C = this.getBodyTable(), A = this.getLockedTable();
  186. if (C.rows[D]) {
  187. C.firstChild.removeChild(C.rows[D])
  188. }
  189. if (A.rows[D]) {
  190. A.firstChild.removeChild(A.rows[D])
  191. }
  192. if (E !== true) {
  193. this.stripeRows(D);
  194. this.syncRowHeights(D, D);
  195. this.layout();
  196. this.fireEvent("rowremoved", this, D, B)
  197. }
  198. },
  199. onLoad : function() {
  200. this.scrollToTop()
  201. },
  202. scrollToTop : function() {
  203. if (this.scroller) {
  204. this.scroller.dom.scrollTop = 0;
  205. this.syncScroll()
  206. }
  207. },
  208. getHeaderPanel : function(A) {
  209. if (A) {
  210. this.headerPanel.show()
  211. }
  212. return this.headerPanel
  213. },
  214. getFooterPanel : function(A) {
  215. if (A) {
  216. this.footerPanel.show()
  217. }
  218. return this.footerPanel
  219. },
  220. initElements : function() {
  221. var C = Ext.Element;
  222. var B = this.grid.getGridEl().dom.firstChild;
  223. var A = B.childNodes;
  224. this.el = new C(B);
  225. this.headerPanel = new C(B.firstChild);
  226. this.headerPanel.enableDisplayMode("block");
  227. this.scroller = new C(A[1]);
  228. this.scrollSizer = new C(this.scroller.dom.firstChild);
  229. this.lockedWrap = new C(A[2]);
  230. this.lockedHd = new C(this.lockedWrap.dom.firstChild);
  231. this.lockedBody = new C(this.lockedWrap.dom.childNodes[1]);
  232. this.mainWrap = new C(A[3]);
  233. this.mainHd = new C(this.mainWrap.dom.firstChild);
  234. this.mainBody = new C(this.mainWrap.dom.childNodes[1]);
  235. this.footerPanel = new C(A[4]);
  236. this.footerPanel.enableDisplayMode("block");
  237. this.focusEl = new C(A[5]);
  238. this.focusEl.swallowEvent("click", true);
  239. this.resizeProxy = new C(A[6]);
  240. this.headerSelector = String.format(
  241. "#{0} td.x-grid-hd, #{1} td.x-grid-hd", this.lockedHd.id,
  242. this.mainHd.id);
  243. this.splitterSelector = String.format(
  244. "#{0} div.x-grid-split, #{1} div.x-grid-split",
  245. this.lockedHd.id, this.mainHd.id)
  246. },
  247. getHeaderCell : function(A) {
  248. return Ext.DomQuery.select(this.headerSelector)[A]
  249. },
  250. getHeaderCellMeasure : function(A) {
  251. return this.getHeaderCell(A).firstChild
  252. },
  253. getHeaderCellText : function(A) {
  254. return this.getHeaderCell(A).firstChild.firstChild
  255. },
  256. getLockedTable : function() {
  257. return this.lockedBody.dom.firstChild
  258. },
  259. getBodyTable : function() {
  260. return this.mainBody.dom.firstChild
  261. },
  262. getLockedRow : function(A) {
  263. return this.getLockedTable().rows[A]
  264. },
  265. getRow : function(A) {
  266. return this.getBodyTable().rows[A]
  267. },
  268. getRowComposite : function(B) {
  269. if (!this.rowEl) {
  270. this.rowEl = new Ext.CompositeElementLite()
  271. }
  272. var D = [], C, A;
  273. if (C = this.getLockedRow(B)) {
  274. D.push(C)
  275. }
  276. if (A = this.getRow(B)) {
  277. D.push(A)
  278. }
  279. this.rowEl.elements = D;
  280. return this.rowEl
  281. },
  282. getCell : function(D, B) {
  283. var A = this.cm.getLockedCount();
  284. var C;
  285. if (B < A) {
  286. C = this.lockedBody.dom.firstChild
  287. } else {
  288. C = this.mainBody.dom.firstChild;
  289. B -= A
  290. }
  291. return C.rows[D].childNodes[B]
  292. },
  293. getCellText : function(B, A) {
  294. return this.getCell(B, A).firstChild.firstChild
  295. },
  296. getCellBox : function(B) {
  297. var A = this.fly(B).getBox();
  298. if (Ext.isOpera) {
  299. A.y = B.offsetTop + this.mainBody.getY()
  300. }
  301. return A
  302. },
  303. getCellIndex : function(A) {
  304. var B = String(A.className).match(this.cellRE);
  305. if (B) {
  306. return parseInt(B[1], 10)
  307. }
  308. return 0
  309. },
  310. findHeaderIndex : function(B) {
  311. var A = Ext.fly(B).findParent("td." + this.hdClass, 6);
  312. return A ? this.getCellIndex(A) : false
  313. },
  314. findHeaderCell : function(B) {
  315. var A = Ext.fly(B).findParent("td." + this.hdClass, 6);
  316. return A ? A : false
  317. },
  318. findRowIndex : function(B) {
  319. if (!B) {
  320. return false
  321. }
  322. var A = Ext.fly(B).findParent("tr." + this.rowClass, 6);
  323. return A ? A.rowIndex : false
  324. },
  325. findCellIndex : function(B) {
  326. var A = this.el.dom;
  327. while (B && B != A) {
  328. if (this.findRE.test(B.className)) {
  329. return this.getCellIndex(B)
  330. }
  331. B = B.parentNode
  332. }
  333. return false
  334. },
  335. getColumnId : function(A) {
  336. return this.cm.getColumnId(A)
  337. },
  338. getSplitters : function() {
  339. if (this.splitterSelector) {
  340. return Ext.DomQuery.select(this.splitterSelector)
  341. } else {
  342. return null
  343. }
  344. },
  345. getSplitter : function(A) {
  346. return this.getSplitters()[A]
  347. },
  348. onRowOver : function(B, A) {
  349. var C;
  350. if ((C = this.findRowIndex(A)) !== false) {
  351. this.getRowComposite(C).addClass("x-grid-row-over")
  352. }
  353. },
  354. onRowOut : function(B, A) {
  355. var C;
  356. if ((C = this.findRowIndex(A)) !== false
  357. && C !== this.findRowIndex(B.getRelatedTarget())) {
  358. this.getRowComposite(C).removeClass("x-grid-row-over")
  359. }
  360. },
  361. renderHeaders : function() {
  362. var J = this.cm;
  363. var F = this.templates.hcell, I = this.templates.header, K = this.templates.hsplit;
  364. var D = [], B = [], H = [], C = [], A = {};
  365. for (var E = 0, G = J.getColumnCount(); E < G; E++) {
  366. A.cellId = "x-grid-hd-0-" + E;
  367. A.splitId = "x-grid-csplit-0-" + E;
  368. A.id = J.getColumnId(E);
  369. A.title = J.getColumnTooltip(E) || "";
  370. A.value = J.getColumnHeader(E) || "";
  371. A.style = (this.grid.enableColumnResize === false
  372. || !J.isResizable(E) || J.isFixed(E))
  373. ? "cursor:default"
  374. : "";
  375. if (!J.isLocked(E)) {
  376. D[D.length] = F.apply(A);
  377. H[H.length] = K.apply(A)
  378. } else {
  379. B[B.length] = F.apply(A);
  380. C[C.length] = K.apply(A)
  381. }
  382. }
  383. return [I.apply({
  384. cells : B.join(""),
  385. splits : C.join("")
  386. }), I.apply({
  387. cells : D.join(""),
  388. splits : H.join("")
  389. })]
  390. },
  391. updateHeaders : function() {
  392. var A = this.renderHeaders();
  393. this.lockedHd.update(A[0]);
  394. this.mainHd.update(A[1])
  395. },
  396. focusRow : function(B) {
  397. var A = this.scroller.dom.scrollLeft;
  398. this.focusCell(B, 0, false);
  399. this.scroller.dom.scrollLeft = A
  400. },
  401. focusCell : function(D, A, C) {
  402. var B = this.ensureVisible(D, A, C);
  403. this.focusEl.alignTo(B, "tl-tl");
  404. if (Ext.isGecko) {
  405. this.focusEl.focus()
  406. } else {
  407. this.focusEl.focus.defer(1, this.focusEl)
  408. }
  409. },
  410. ensureVisible : function(O, E, D) {
  411. if (typeof O != "number") {
  412. O = O.rowIndex
  413. }
  414. if (O < 0 && O >= this.ds.getCount()) {
  415. return
  416. }
  417. E = (E !== undefined ? E : 0);
  418. var M = this.grid.colModel;
  419. while (M.isHidden(E)) {
  420. E++
  421. }
  422. var C = this.getCell(O, E);
  423. if (!C) {
  424. return
  425. }
  426. var J = this.scroller.dom;
  427. var N = parseInt(C.offsetTop, 10);
  428. var I = parseInt(C.offsetLeft, 10);
  429. var L = N + C.offsetHeight;
  430. var G = I + C.offsetWidth;
  431. var A = J.clientHeight - this.mainHd.dom.offsetHeight;
  432. var K = parseInt(J.scrollTop, 10);
  433. var F = parseInt(J.scrollLeft, 10);
  434. var H = K + A;
  435. var B = F + J.clientWidth;
  436. if (N < K) {
  437. J.scrollTop = N
  438. } else {
  439. if (L > H) {
  440. J.scrollTop = L - A
  441. }
  442. }
  443. if (D !== false) {
  444. if (I < F) {
  445. J.scrollLeft = I
  446. } else {
  447. if (G > B) {
  448. J.scrollLeft = G - J.clientWidth
  449. }
  450. }
  451. }
  452. return C
  453. },
  454. updateColumns : function() {
  455. this.grid.stopEditing();
  456. var B = this.grid.colModel, E = this.getColumnIds();
  457. var F = 0;
  458. for (var D = 0, A = B.getColumnCount(); D < A; D++) {
  459. var C = B.getColumnWidth(D);
  460. this.css.updateRule(this.colSelector + E[D], "width",
  461. (C - this.borderWidth) + "px");
  462. this.css.updateRule(this.hdSelector + E[D], "width",
  463. (C - this.borderWidth) + "px")
  464. }
  465. this.updateSplitters()
  466. },
  467. generateRules : function(B) {
  468. var C = [];
  469. for (var D = 0, A = B.getColumnCount(); D < A; D++) {
  470. var H = B.getColumnId(D);
  471. var G = "";
  472. if (B.config[D].align) {
  473. G = "text-align:" + B.config[D].align + ";"
  474. }
  475. var F = "";
  476. if (B.isHidden(D)) {
  477. F = "display:none;"
  478. }
  479. var E = "width:" + (B.getColumnWidth(D) - this.borderWidth) + "px;";
  480. C.push(this.colSelector, H, " {\n", B.config[D].css, G, E, "\n}\n",
  481. this.hdSelector, H, " {\n", G, E, "}\n", this.tdSelector,
  482. H, " {\n", F, "\n}\n", this.splitSelector, H, " {\n", F,
  483. "\n}\n")
  484. }
  485. return Ext.util.CSS.createStyleSheet(C.join(""))
  486. },
  487. updateSplitters : function() {
  488. var B = this.cm, F = this.getSplitters();
  489. if (F) {
  490. var G = 0, D = true;
  491. for (var E = 0, A = B.getColumnCount(); E < A; E++) {
  492. if (B.isHidden(E)) {
  493. continue
  494. }
  495. var C = B.getColumnWidth(E);
  496. if (!B.isLocked(E) && D) {
  497. G = 0;
  498. D = false
  499. }
  500. G += C;
  501. F[E].style.left = (G - this.splitOffset) + "px"
  502. }
  503. }
  504. },
  505. handleHiddenChange : function(B, A, C) {
  506. if (C) {
  507. this.hideColumn(A)
  508. } else {
  509. this.unhideColumn(A)
  510. }
  511. },
  512. hideColumn : function(A) {
  513. var B = this.getColumnId(A);
  514. this.css.updateRule(this.tdSelector + B, "display", "none");
  515. this.css.updateRule(this.splitSelector + B, "display", "none");
  516. if (Ext.isSafari) {
  517. this.updateHeaders()
  518. }
  519. this.updateSplitters();
  520. this.layout()
  521. },
  522. unhideColumn : function(A) {
  523. var B = this.getColumnId(A);
  524. this.css.updateRule(this.tdSelector + B, "display", "");
  525. this.css.updateRule(this.splitSelector + B, "display", "");
  526. if (Ext.isSafari) {
  527. this.updateHeaders()
  528. }
  529. this.updateSplitters();
  530. this.layout()
  531. },
  532. insertRows : function(B, F, D, E) {
  533. if (F == 0 && D == B.getCount() - 1) {
  534. this.refresh()
  535. } else {
  536. if (!E) {
  537. this.fireEvent("beforerowsinserted", this, F, D)
  538. }
  539. var C = this.getScrollState();
  540. var A = this.renderRows(F, D);
  541. this.bufferRows(A[0], this.getLockedTable(), F);
  542. this.bufferRows(A[1], this.getBodyTable(), F);
  543. this.restoreScroll(C);
  544. if (!E) {
  545. this.fireEvent("rowsinserted", this, F, D);
  546. this.syncRowHeights(F, D);
  547. this.stripeRows(F);
  548. this.layout()
  549. }
  550. }
  551. },
  552. bufferRows : function(I, E, D) {
  553. var G = null, H = E.rows, B = E.tBodies[0];
  554. if (D < H.length) {
  555. G = H[D]
  556. }
  557. var F = document.createElement("div");
  558. F.innerHTML = "<table><tbody>" + I + "</tbody></table>";
  559. var J = F.firstChild.rows;
  560. for (var A = 0, C = J.length; A < C; A++) {
  561. if (G) {
  562. B.insertBefore(J[0], G)
  563. } else {
  564. B.appendChild(J[0])
  565. }
  566. }
  567. F.innerHTML = "";
  568. F = null
  569. },
  570. deleteRows : function(B, F, D) {
  571. if (B.getRowCount() < 1) {
  572. this.fireEvent("beforerefresh", this);
  573. this.mainBody.update("");
  574. this.lockedBody.update("");
  575. this.fireEvent("refresh", this)
  576. } else {
  577. this.fireEvent("beforerowsdeleted", this, F, D);
  578. var A = this.getBodyTable();
  579. var C = A.firstChild;
  580. var E = A.rows;
  581. for (var G = F; G <= D; G++) {
  582. C.removeChild(E[F])
  583. }
  584. this.stripeRows(F);
  585. this.fireEvent("rowsdeleted", this, F, D)
  586. }
  587. },
  588. updateRows : function(D, C, B) {
  589. var A = this.getScrollState();
  590. this.refresh();
  591. this.restoreScroll(A)
  592. },
  593. handleSort : function(D, C, A, B) {
  594. if (!B) {
  595. this.refresh()
  596. }
  597. this.updateHeaderSortState()
  598. },
  599. getScrollState : function() {
  600. var A = this.scroller.dom;
  601. return {
  602. left : A.scrollLeft,
  603. top : A.scrollTop
  604. }
  605. },
  606. stripeRows : function(F) {
  607. if (!this.grid.stripeRows || this.ds.getCount() < 1) {
  608. return
  609. }
  610. F = F || 0;
  611. var J = this.getBodyTable().rows;
  612. var D = this.getLockedTable().rows;
  613. var G = " x-grid-row-alt ";
  614. for (var B = F, C = J.length; B < C; B++) {
  615. var I = J[B], E = D[B];
  616. var A = ((B + 1) % 2 == 0);
  617. var H = (" " + I.className + " ").indexOf(G) != -1;
  618. if (A == H) {
  619. continue
  620. }
  621. if (A) {
  622. I.className += " x-grid-row-alt"
  623. } else {
  624. I.className = I.className.replace("x-grid-row-alt", "")
  625. }
  626. if (E) {
  627. E.className = I.className
  628. }
  629. }
  630. },
  631. restoreScroll : function(A) {
  632. var B = this.scroller.dom;
  633. B.scrollLeft = A.left;
  634. B.scrollTop = A.top;
  635. this.syncScroll()
  636. },
  637. syncScroll : function() {
  638. var D = this.scroller.dom;
  639. var B = this.mainHd.dom;
  640. var A = this.mainBody.dom;
  641. var C = this.lockedBody.dom;
  642. B.scrollLeft = A.scrollLeft = D.scrollLeft;
  643. C.scrollTop = A.scrollTop = D.scrollTop
  644. },
  645. handleScroll : function(A) {
  646. this.syncScroll();
  647. var B = this.scroller.dom;
  648. this.grid.fireEvent("bodyscroll", B.scrollLeft, B.scrollTop);
  649. A.stopEvent()
  650. },
  651. handleWheel : function(A) {
  652. var B = A.getWheelDelta();
  653. this.scroller.dom.scrollTop -= B * 22;
  654. this.lockedBody.dom.scrollTop = this.mainBody.dom.scrollTop = this.scroller.dom.scrollTop;
  655. A.stopEvent()
  656. },
  657. renderRows : function(J, D) {
  658. var F = this.grid, H = F.colModel, B = F.dataSource, K = F.stripeRows;
  659. var I = H.getColumnCount();
  660. if (B.getCount() < 1) {
  661. return ["", ""]
  662. }
  663. var G = [];
  664. for (var E = 0; E < I; E++) {
  665. var A = H.getDataIndex(E);
  666. G[E] = {
  667. name : typeof A == "undefined" ? B.fields.get(E).name : A,
  668. renderer : H.getRenderer(E),
  669. id : H.getColumnId(E),
  670. locked : H.isLocked(E)
  671. }
  672. }
  673. J = J || 0;
  674. D = typeof D == "undefined" ? B.getCount() - 1 : D;
  675. var C = B.getRange(J, D);
  676. return this.doRender(G, C, B, J, I, K)
  677. },
  678. doRender : Ext.isGecko ? function(D, G, L, A, K, P) {
  679. var B = this.templates, C = B.cell, E = B.row;
  680. var T = "", W = "", M, F, U, N = {}, H = {}, J, I;
  681. for (var O = 0, R = G.length; O < R; O++) {
  682. J = G[O];
  683. M = "";
  684. F = "";
  685. I = (O + A);
  686. for (var Q = 0; Q < K; Q++) {
  687. U = D[Q];
  688. N.cellId = "x-grid-cell-" + I + "-" + Q;
  689. N.id = U.id;
  690. N.css = N.attr = "";
  691. N.value = U.renderer(J.data[U.name], N, J, I, Q, L);
  692. if (N.value == undefined || N.value === "") {
  693. N.value = "&#160;"
  694. }
  695. if (J.dirty && typeof J.modified[U.name] !== "undefined") {
  696. N.css += N.css ? " x-grid-dirty-cell" : "x-grid-dirty-cell"
  697. }
  698. var S = C.apply(N);
  699. if (!U.locked) {
  700. M += S
  701. } else {
  702. F += S
  703. }
  704. }
  705. var V = [];
  706. if (P && ((I + 1) % 2 == 0)) {
  707. V[0] = "x-grid-row-alt"
  708. }
  709. if (J.dirty) {
  710. V[1] = " x-grid-dirty-row"
  711. }
  712. H.cells = F;
  713. if (this.getRowClass) {
  714. V[2] = this.getRowClass(J, I)
  715. }
  716. H.alt = V.join(" ");
  717. W += E.apply(H);
  718. H.cells = M;
  719. T += E.apply(H)
  720. }
  721. return [W, T]
  722. } : function(D, G, L, A, K, P) {
  723. var B = this.templates, C = B.cell, E = B.row;
  724. var T = [], W = [], M, F, U, N = {}, H = {}, J, I;
  725. for (var O = 0, R = G.length; O < R; O++) {
  726. J = G[O];
  727. M = [];
  728. F = [];
  729. I = (O + A);
  730. for (var Q = 0; Q < K; Q++) {
  731. U = D[Q];
  732. N.cellId = "x-grid-cell-" + I + "-" + Q;
  733. N.id = U.id;
  734. N.css = N.attr = "";
  735. N.value = U.renderer(J.data[U.name], N, J, I, Q, L);
  736. if (N.value == undefined || N.value === "") {
  737. N.value = "&#160;"
  738. }
  739. if (J.dirty && typeof J.modified[U.name] !== "undefined") {
  740. N.css += N.css ? " x-grid-dirty-cell" : "x-grid-dirty-cell"
  741. }
  742. var S = C.apply(N);
  743. if (!U.locked) {
  744. M[M.length] = S
  745. } else {
  746. F[F.length] = S
  747. }
  748. }
  749. var V = [];
  750. if (P && ((I + 1) % 2 == 0)) {
  751. V[0] = "x-grid-row-alt"
  752. }
  753. if (J.dirty) {
  754. V[1] = " x-grid-dirty-row"
  755. }
  756. H.cells = F;
  757. if (this.getRowClass) {
  758. V[2] = this.getRowClass(J, I)
  759. }
  760. H.alt = V.join(" ");
  761. H.cells = F.join("");
  762. W[W.length] = E.apply(H);
  763. H.cells = M.join("");
  764. T[T.length] = E.apply(H)
  765. }
  766. return [W.join(""), T.join("")]
  767. },
  768. renderBody : function() {
  769. var B = this.renderRows();
  770. var A = this.templates.body;
  771. return [A.apply({
  772. rows : B[0]
  773. }), A.apply({
  774. rows : B[1]
  775. })]
  776. },
  777. refresh : function(B) {
  778. this.fireEvent("beforerefresh", this);
  779. this.grid.stopEditing();
  780. var A = this.renderBody();
  781. this.lockedBody.update(A[0]);
  782. this.mainBody.update(A[1]);
  783. if (B === true) {
  784. this.updateHeaders();
  785. this.updateColumns();
  786. this.updateSplitters();
  787. this.updateHeaderSortState()
  788. }
  789. this.syncRowHeights();
  790. this.layout();
  791. this.fireEvent("refresh", this)
  792. },
  793. handleColumnMove : function(A, D, B) {
  794. this.indexMap = null;
  795. var C = this.getScrollState();
  796. this.refresh(true);
  797. this.restoreScroll(C);
  798. this.afterMove(B)
  799. },
  800. afterMove : function(A) {
  801. if (this.enableMoveAnim && Ext.enableFx) {
  802. this.fly(this.getHeaderCell(A).firstChild).highlight(this.hlColor)
  803. }
  804. },
  805. updateCell : function(C, E, F) {
  806. var H = this.getColumnIndexByDataIndex(F);
  807. if (typeof H == "undefined") {
  808. return
  809. }
  810. var G = this.grid.colModel;
  811. var I = this.getCell(E, H);
  812. var J = this.getCellText(E, H);
  813. var A = {
  814. cellId : "x-grid-cell-" + E + "-" + H,
  815. id : G.getColumnId(H),
  816. css : H == G.getColumnCount() - 1 ? "x-grid-col-last" : ""
  817. };
  818. var D = G.getRenderer(H);
  819. var B = D(C.getValueAt(E, F), A, E, H, C);
  820. if (typeof B == "undefined" || B === "") {
  821. B = "&#160;"
  822. }
  823. J.innerHTML = B;
  824. I.className = this.cellClass + " " + A.cellId + " " + A.css;
  825. this.syncRowHeights(E, E)
  826. },
  827. calcColumnWidth : function(I, A) {
  828. var H = 0;
  829. if (this.grid.autoSizeHeaders) {
  830. var D = this.getHeaderCellMeasure(I);
  831. H = Math.max(H, D.scrollWidth)
  832. }
  833. var B, E;
  834. if (this.cm.isLocked(I)) {
  835. B = this.getLockedTable();
  836. E = I
  837. } else {
  838. B = this.getBodyTable();
  839. E = I - this.cm.getLockedCount()
  840. }
  841. if (B && B.rows) {
  842. var J = B.rows;
  843. var F = Math.min(A || J.length, J.length);
  844. for (var C = 0; C < F; C++) {
  845. var G = J[C].childNodes[E].firstChild;
  846. H = Math.max(H, G.scrollWidth)
  847. }
  848. }
  849. return H + 5
  850. },
  851. autoSizeColumn : function(C, A, B) {
  852. if (this.cm.isHidden(C)) {
  853. return
  854. }
  855. if (A) {
  856. var E = this.cm.getColumnId(C);
  857. this.css.updateRule(this.colSelector + E, "width",
  858. this.grid.minColumnWidth + "px");
  859. if (this.grid.autoSizeHeaders) {
  860. this.css.updateRule(this.hdSelector + E, "width",
  861. this.grid.minColumnWidth + "px")
  862. }
  863. }
  864. var D = this.calcColumnWidth(C);
  865. this.cm.setColumnWidth(C, Math.max(this.grid.minColumnWidth, D), B);
  866. if (!B) {
  867. this.grid.fireEvent("columnresize", C, D)
  868. }
  869. },
  870. autoSizeColumns : function() {
  871. var A = this.grid.colModel;
  872. var C = A.getColumnCount();
  873. for (var B = 0; B < C; B++) {
  874. this.autoSizeColumn(B, true, true)
  875. }
  876. if (A.getTotalWidth() < this.scroller.dom.clientWidth) {
  877. this.fitColumns()
  878. } else {
  879. this.updateColumns();
  880. this.layout()
  881. }
  882. },
  883. fitColumns : function(C) {
  884. var H = this.grid.colModel;
  885. var I = H.getColumnCount();
  886. var F = [];
  887. var B = 0;
  888. var D, G;
  889. for (D = 0; D < I; D++) {
  890. if (!H.isHidden(D) && !H.isFixed(D)) {
  891. G = H.getColumnWidth(D);
  892. F.push(D);
  893. F.push(G);
  894. B += G
  895. }
  896. }
  897. var E = Math.min(this.scroller.dom.clientWidth, this.el.getWidth());
  898. if (C) {
  899. E -= 17
  900. }
  901. var A = (E - H.getTotalWidth()) / B;
  902. while (F.length) {
  903. G = F.pop();
  904. D = F.pop();
  905. H.setColumnWidth(D, Math.floor(G + G * A), true)
  906. }
  907. this.updateColumns();
  908. this.layout()
  909. },
  910. onRowSelect : function(B) {
  911. var A = this.getRowComposite(B);
  912. A.addClass("x-grid-row-selected")
  913. },
  914. onRowDeselect : function(B) {
  915. var A = this.getRowComposite(B);
  916. A.removeClass("x-grid-row-selected")
  917. },
  918. onCellSelect : function(C, B) {
  919. var A = this.getCell(C, B);
  920. if (A) {
  921. Ext.fly(A).addClass("x-grid-cell-selected")
  922. }
  923. },
  924. onCellDeselect : function(C, B) {
  925. var A = this.getCell(C, B);
  926. if (A) {
  927. Ext.fly(A).removeClass("x-grid-cell-selected")
  928. }
  929. },
  930. updateHeaderSortState : function() {
  931. var B = this.ds.getSortState();
  932. if (!B) {
  933. return
  934. }
  935. this.sortState = B;
  936. var E = this.cm.findColumnIndex(B.field);
  937. if (E != -1) {
  938. var A = B.direction;
  939. var D = this.sortClasses;
  940. var C = this.el.select(this.headerSelector).removeClass(D);
  941. C.item(E).addClass(D[A == "DESC" ? 1 : 0])
  942. }
  943. },
  944. handleHeaderClick : function(D, C) {
  945. if (this.headersDisabled) {
  946. return
  947. }
  948. var B = D.store, A = D.colModel;
  949. if (!A.isSortable(C)) {
  950. return
  951. }
  952. D.stopEditing();
  953. B.sort(A.getDataIndex(C))
  954. },
  955. destroy : function() {
  956. if (this.colMenu) {
  957. this.colMenu.removeAll();
  958. Ext.menu.MenuMgr.unregister(this.colMenu);
  959. this.colMenu.getEl().remove();
  960. delete this.colMenu
  961. }
  962. if (this.hmenu) {
  963. this.hmenu.removeAll();
  964. Ext.menu.MenuMgr.unregister(this.hmenu);
  965. this.hmenu.getEl().remove();
  966. delete this.hmenu
  967. }
  968. if (this.grid.enableColumnMove) {
  969. var C = Ext.dd.DDM.ids["gridHeader" + this.grid.getGridEl().id];
  970. if (C) {
  971. for (var A in C) {
  972. if (!C[A].config.isTarget && C[A].dragElId) {
  973. var B = C[A].dragElId;
  974. C[A].unreg();
  975. Ext.get(B).remove()
  976. } else {
  977. if (C[A].config.isTarget) {
  978. C[A].proxyTop.remove();
  979. C[A].proxyBottom.remove();
  980. C[A].unreg()
  981. }
  982. }
  983. if (Ext.dd.DDM.locationCache[A]) {
  984. delete Ext.dd.DDM.locationCache[A]
  985. }
  986. }
  987. delete Ext.dd.DDM.ids["gridHeader" + this.grid.getGridEl().id]
  988. }
  989. }
  990. this.bind(null, null);
  991. Ext.EventManager.removeResizeListener(this.onWindowResize, this)
  992. },
  993. handleLockChange : function() {
  994. this.refresh(true)
  995. },
  996. onDenyColumnLock : function() {
  997. },
  998. onDenyColumnHide : function() {
  999. },
  1000. handleHdMenuClick : function(D) {
  1001. var B = this.hdCtxIndex;
  1002. var A = this.cm, E = this.ds;
  1003. switch (D.id) {
  1004. case "asc" :
  1005. E.sort(A.getDataIndex(B), "ASC");
  1006. break;
  1007. case "desc" :
  1008. E.sort(A.getDataIndex(B), "DESC");
  1009. break;
  1010. case "lock" :
  1011. var C = A.getLockedCount();
  1012. if (A.getColumnCount(true) <= C + 1) {
  1013. this.onDenyColumnLock();
  1014. return
  1015. }
  1016. if (C != B) {
  1017. A.setLocked(B, true, true);
  1018. A.moveColumn(B, C);
  1019. this.grid.fireEvent("columnmove", B, C)
  1020. } else {
  1021. A.setLocked(B, true)
  1022. }
  1023. break;
  1024. case "unlock" :
  1025. var C = A.getLockedCount();
  1026. if ((C - 1) != B) {
  1027. A.setLocked(B, false, true);
  1028. A.moveColumn(B, C - 1);
  1029. this.grid.fireEvent("columnmove", B, C - 1)
  1030. } else {
  1031. A.setLocked(B, false)
  1032. }
  1033. break;
  1034. default :
  1035. B = A.getIndexById(D.id.substr(4));
  1036. if (B != -1) {
  1037. if (D.checked && A.getColumnCount(true) <= 1) {
  1038. this.onDenyColumnHide();
  1039. return false
  1040. }
  1041. A.setHidden(B, D.checked)
  1042. }
  1043. }
  1044. return true
  1045. },
  1046. beforeColMenuShow : function() {
  1047. var A = this.cm, C = A.getColumnCount();
  1048. this.colMenu.removeAll();
  1049. for (var B = 0; B < C; B++) {
  1050. this.colMenu.add(new Ext.menu.CheckItem({
  1051. id : "col-" + A.getColumnId(B),
  1052. text : A.getColumnHeader(B),
  1053. checked : !A.isHidden(B),
  1054. hideOnClick : false
  1055. }))
  1056. }
  1057. },
  1058. handleHdCtx : function(D, C, F) {
  1059. F.stopEvent();
  1060. var E = this.getHeaderCell(C);
  1061. this.hdCtxIndex = C;
  1062. var B = this.hmenu.items, A = this.cm;
  1063. B.get("asc").setDisabled(!A.isSortable(C));
  1064. B.get("desc").setDisabled(!A.isSortable(C));
  1065. if (this.grid.enableColLock !== false) {
  1066. B.get("lock").setDisabled(A.isLocked(C));
  1067. B.get("unlock").setDisabled(!A.isLocked(C))
  1068. }
  1069. this.hmenu.show(E, "tl-bl")
  1070. },
  1071. handleHdOver : function(B) {
  1072. var A = this.findHeaderCell(B.getTarget());
  1073. if (A && !this.headersDisabled) {
  1074. if (this.grid.colModel.isSortable(this.getCellIndex(A))) {
  1075. this.fly(A).addClass("x-grid-hd-over")
  1076. }
  1077. }
  1078. },
  1079. handleHdOut : function(B) {
  1080. var A = this.findHeaderCell(B.getTarget());
  1081. if (A) {
  1082. this.fly(A).removeClass("x-grid-hd-over")
  1083. }
  1084. },
  1085. handleSplitDblClick : function(C, B) {
  1086. var A = this.getCellIndex(B);
  1087. if (this.grid.enableColumnResize !== false && this.cm.isResizable(A)
  1088. && !this.cm.isFixed(A)) {
  1089. this.autoSizeColumn(A, true);
  1090. this.layout()
  1091. }
  1092. },
  1093. render : function() {
  1094. var B = this.cm;
  1095. var D = B.getColumnCount();
  1096. if (this.grid.monitorWindowResize === true) {
  1097. Ext.EventManager.onWindowResize(this.onWindowResize, this, true)
  1098. }
  1099. var E = this.renderHeaders();
  1100. var A = this.templates.body.apply({
  1101. rows : ""
  1102. });
  1103. var C = this.templates.master.apply({
  1104. lockedBody : A,
  1105. body : A,
  1106. lockedHeader : E[0],
  1107. header : E[1]
  1108. });
  1109. this.grid.getGridEl().dom.innerHTML = C;
  1110. this.initElements();
  1111. this.scroller.on("scroll", this.handleScroll, this);
  1112. this.lockedBody.on("mousewheel", this.handleWheel, this);
  1113. this.mainBody.on("mousewheel", this.handleWheel, this);
  1114. this.mainHd.on("mouseover", this.handleHdOver, this);
  1115. this.mainHd.on("mouseout", this.handleHdOut, this);
  1116. this.mainHd.on("dblclick", this.handleSplitDblClick, this, {
  1117. delegate : "." + this.splitClass
  1118. });
  1119. this.lockedHd.on("mouseover", this.handleHdOver, this);
  1120. this.lockedHd.on("mouseout", this.handleHdOut, this);
  1121. this.lockedHd.on("dblclick", this.handleSplitDblClick, this, {
  1122. delegate : "." + this.splitClass
  1123. });
  1124. if (this.grid.enableColumnResize !== false && Ext.grid.SplitDragZone) {
  1125. new Ext.grid.SplitDragZone(this.grid, this.lockedHd.dom,
  1126. this.mainHd.dom)
  1127. }
  1128. this.updateSplitters();
  1129. if (this.grid.enableColumnMove && Ext.grid.HeaderDragZone) {
  1130. new Ext.grid.HeaderDragZone(this.grid, this.lockedHd.dom,
  1131. this.mainHd.dom);
  1132. new Ext.grid.HeaderDropZone(this.grid, this.lockedHd.dom,
  1133. this.mainHd.dom)
  1134. }
  1135. if (this.grid.enableCtxMenu !== false && Ext.menu.Menu) {
  1136. this.hmenu = new Ext.menu.Menu({
  1137. id : this.grid.id + "-hctx"
  1138. });
  1139. this.hmenu.add({
  1140. id : "asc",
  1141. text : this.sortAscText,
  1142. cls : "xg-hmenu-sort-asc"
  1143. }, {
  1144. id : "desc",
  1145. text : this.sortDescText,
  1146. cls : "xg-hmenu-sort-desc"
  1147. });
  1148. if (this.grid.enableColLock !== false) {
  1149. this.hmenu.add("-", {
  1150. id : "lock",
  1151. text : this.lockText,
  1152. cls : "xg-hmenu-lock"
  1153. }, {
  1154. id : "unlock",
  1155. text : this.unlockText,
  1156. cls : "xg-hmenu-unlock"
  1157. })
  1158. }
  1159. if (this.grid.enableColumnHide !== false) {
  1160. this.colMenu = new Ext.menu.Menu({
  1161. id : this.grid.id + "-hcols-menu"
  1162. });
  1163. this.colMenu.on("beforeshow", this.beforeColMenuShow, this);
  1164. this.colMenu.on("itemclick", this.handleHdMenuClick, this);
  1165. this.hmenu.add("-", {
  1166. id : "columns",
  1167. text : this.columnsText,
  1168. menu : this.colMenu
  1169. })
  1170. }
  1171. this.hmenu.on("itemclick", this.handleHdMenuClick, this);
  1172. this.grid.on("headercontextmenu", this.handleHdCtx, this)
  1173. }
  1174. if ((this.grid.enableDragDrop || this.grid.enableDrag)
  1175. && Ext.grid.GridDragZone) {
  1176. this.dd = new Ext.grid.GridDragZone(this.grid, {
  1177. ddGroup : this.grid.ddGroup || "GridDD"
  1178. })
  1179. }
  1180. this.updateHeaderSortState();
  1181. this.beforeInitialResize();
  1182. this.layout(true);
  1183. this.renderPhase2.defer(1, this)
  1184. },
  1185. renderPhase2 : function() {
  1186. this.refresh();
  1187. if (this.grid.autoSizeColumns) {
  1188. this.autoSizeColumns()
  1189. }
  1190. },
  1191. beforeInitialResize : function() {
  1192. },
  1193. onColumnSplitterMoved : function(C, B) {
  1194. this.userResized = true;
  1195. var A = this.grid.colModel;
  1196. A.setColumnWidth(C, B, true);
  1197. var D = A.getColumnId(C);
  1198. this.css.updateRule(this.colSelector + D, "width",
  1199. (B - this.borderWidth) + "px");
  1200. this.css.updateRule(this.hdSelector + D, "width",
  1201. (B - this.borderWidth) + "px");
  1202. this.updateSplitters();
  1203. this.layout();
  1204. this.grid.fireEvent("columnresize", C, B)
  1205. },
  1206. syncRowHeights : function(I, E) {
  1207. if (this.grid.enableRowHeightSync === true
  1208. && this.cm.getLockedCount() > 0) {
  1209. I = I || 0;
  1210. var F = this.getBodyTable().rows;
  1211. var H = this.getLockedTable().rows;
  1212. var G = F.length - 1;
  1213. E = Math.min(E || G, G);
  1214. for (var C = I; C <= E; C++) {
  1215. var A = F[C], B = H[C];
  1216. var D = Math.max(A.offsetHeight, B.offsetHeight);
  1217. A.style.height = B.style.height = D + "px"
  1218. }
  1219. }
  1220. },
  1221. layout : function(B, C) {
  1222. var W = this.grid;
  1223. var E = W.autoHeight;
  1224. var L = 16;
  1225. var a = W.getGridEl(), H = this.cm, I = W.autoExpandColumn, O = this;
  1226. if (!a.dom.offsetWidth) {
  1227. if (B) {
  1228. this.lockedWrap.show();
  1229. this.mainWrap.show()
  1230. }
  1231. return
  1232. }
  1233. var V = this.cm.isLocked(0);
  1234. var F = this.headerPanel.getHeight();
  1235. var G = this.footerPanel.getHeight();
  1236. if (E) {
  1237. var K = this.getBodyTable().offsetHeight + F + G
  1238. + this.mainHd.getHeight();
  1239. var U = K + a.getBorderWidth("tb");
  1240. if (W.maxHeight) {
  1241. U = Math.min(W.maxHeight, U)
  1242. }
  1243. a.setHeight(U)
  1244. }
  1245. if (W.autoWidth) {
  1246. a.setWidth(H.getTotalWidth() + a.getBorderWidth("lr"))
  1247. }
  1248. var N = this.scroller;
  1249. var T = a.getSize(true);
  1250. this.el.setSize(T.width, T.height);
  1251. this.headerPanel.setWidth(T.width);
  1252. this.footerPanel.setWidth(T.width);
  1253. var M = this.mainHd.getHeight();
  1254. var Q = T.width;
  1255. var d = T.height - (F + G);
  1256. N.setSize(Q, d);
  1257. var Z = this.getBodyTable();
  1258. var S = V ? Math.max(this.getLockedTable().offsetWidth,
  1259. this.lockedHd.dom.firstChild.offsetWidth) : 0;
  1260. var X = Z.offsetHeight;
  1261. var J = S + Z.offsetWidth;
  1262. var b = false, Y = false;
  1263. this.scrollSizer.setSize(J, X + M);
  1264. var D = this.lockedWrap, P = this.mainWrap;
  1265. var R = this.lockedBody, A = this.mainBody;
  1266. setTimeout(function() {
  1267. var j = N.dom.offsetTop;
  1268. var e = N.dom.clientWidth, k = N.dom.clientHeight;
  1269. D.setTop(j);
  1270. D.setSize(S, k);
  1271. P.setLeftTop(S, j);
  1272. P.setSize(e - S, k);
  1273. R.setHeight(k - M);
  1274. A.setHeight(k - M);
  1275. if (C !== true && !O.userResized && I) {
  1276. var i = H.getIndexById(I);
  1277. var f = H.getTotalWidth(false);
  1278. var g = H.getColumnWidth(i);
  1279. var c = Math
  1280. .min(
  1281. Math
  1282. .max(
  1283. ((e - f) + g - 2)
  1284. - (e <= N.dom.offsetWidth
  1285. ? 0
  1286. : 18),
  1287. W.autoExpandMin),
  1288. W.autoExpandMax);
  1289. if (g != c) {
  1290. H.setColumnWidth(i, c, true);
  1291. O.css.updateRule(O.colSelector + I, "width",
  1292. (c - O.borderWidth) + "px");
  1293. O.css.updateRule(O.hdSelector + I, "width",
  1294. (c - O.borderWidth) + "px");
  1295. O.updateSplitters();
  1296. O.layout(false, true)
  1297. }
  1298. }
  1299. if (B) {
  1300. D.show();
  1301. P.show()
  1302. }
  1303. }, 10)
  1304. },
  1305. onWindowResize : function() {
  1306. if (!this.grid.monitorWindowResize || this.grid.autoHeight) {
  1307. return
  1308. }
  1309. this.layout()
  1310. },
  1311. appendFooter : function(A) {
  1312. return null
  1313. },
  1314. sortAscText : "Sort Ascending",
  1315. sortDescText : "Sort Descending",
  1316. lockText : "Lock Column",
  1317. unlockText : "Unlock Column",
  1318. columnsText : "Columns"
  1319. });