Table2.html 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-panel-Table'>/**
  19. </span> * @author Nicolas Ferrero
  20. *
  21. * TablePanel is the basis of both {@link Ext.tree.Panel TreePanel} and {@link Ext.grid.Panel GridPanel}.
  22. *
  23. * TablePanel aggregates:
  24. *
  25. * - a Selection Model
  26. * - a View
  27. * - a Store
  28. * - Scrollers
  29. * - Ext.grid.header.Container
  30. */
  31. Ext.define('Ext.panel.Table', {
  32. extend: 'Ext.panel.Panel',
  33. alias: 'widget.tablepanel',
  34. uses: [
  35. 'Ext.selection.RowModel',
  36. 'Ext.selection.CellModel',
  37. 'Ext.selection.CheckboxModel',
  38. 'Ext.grid.PagingScroller',
  39. 'Ext.grid.header.Container',
  40. 'Ext.grid.Lockable'
  41. ],
  42. extraBaseCls: Ext.baseCSSPrefix + 'grid',
  43. extraBodyCls: Ext.baseCSSPrefix + 'grid-body',
  44. layout: 'fit',
  45. <span id='Ext-panel-Table-property-hasView'> /**
  46. </span> * @property {Boolean} hasView
  47. * True to indicate that a view has been injected into the panel.
  48. */
  49. hasView: false,
  50. // each panel should dictate what viewType and selType to use
  51. <span id='Ext-panel-Table-cfg-viewType'> /**
  52. </span> * @cfg {String} viewType
  53. * An xtype of view to use. This is automatically set to 'gridview' by {@link Ext.grid.Panel Grid}
  54. * and to 'treeview' by {@link Ext.tree.Panel Tree}.
  55. * @protected
  56. */
  57. viewType: null,
  58. <span id='Ext-panel-Table-cfg-viewConfig'> /**
  59. </span> * @cfg {Object} viewConfig
  60. * A config object that will be applied to the grid's UI view. Any of the config options available for
  61. * {@link Ext.view.Table} can be specified here. This option is ignored if {@link #view} is specified.
  62. */
  63. <span id='Ext-panel-Table-cfg-view'> /**
  64. </span> * @cfg {Ext.view.Table} view
  65. * The {@link Ext.view.Table} used by the grid. Use {@link #viewConfig} to just supply some config options to
  66. * view (instead of creating an entire View instance).
  67. */
  68. <span id='Ext-panel-Table-cfg-selType'> /**
  69. </span> * @cfg {String} selType
  70. * An xtype of selection model to use. Defaults to 'rowmodel'. This is used to create selection model if just
  71. * a config object or nothing at all given in {@link #selModel} config.
  72. */
  73. selType: 'rowmodel',
  74. <span id='Ext-panel-Table-cfg-selModel'> /**
  75. </span> * @cfg {Ext.selection.Model/Object} selModel
  76. * A {@link Ext.selection.Model selection model} instance or config object. In latter case the {@link #selType}
  77. * config option determines to which type of selection model this config is applied.
  78. */
  79. <span id='Ext-panel-Table-cfg-multiSelect'> /**
  80. </span> * @cfg {Boolean} [multiSelect=false]
  81. * True to enable 'MULTI' selection mode on selection model.
  82. * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'MULTI' instead.
  83. */
  84. <span id='Ext-panel-Table-cfg-simpleSelect'> /**
  85. </span> * @cfg {Boolean} [simpleSelect=false]
  86. * True to enable 'SIMPLE' selection mode on selection model.
  87. * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'SIMPLE' instead.
  88. */
  89. <span id='Ext-panel-Table-cfg-store'> /**
  90. </span> * @cfg {Ext.data.Store} store (required)
  91. * The {@link Ext.data.Store Store} the grid should use as its data source.
  92. */
  93. <span id='Ext-panel-Table-cfg-scroll'> /**
  94. </span> * @cfg {String/Boolean} scroll
  95. * Scrollers configuration. Valid values are 'both', 'horizontal' or 'vertical'.
  96. * True implies 'both'. False implies 'none'.
  97. */
  98. scroll: true,
  99. <span id='Ext-panel-Table-cfg-columns'> /**
  100. </span> * @cfg {Ext.grid.column.Column[]/Object} columns
  101. * An array of {@link Ext.grid.column.Column column} definition objects which define all columns that appear in this
  102. * grid. Each column definition provides the header text for the column, and a definition of where the data for that
  103. * column comes from.
  104. *
  105. * This can also be a configuration object for a {Ext.grid.header.Container HeaderContainer} which may override
  106. * certain default configurations if necessary. For example, the special layout may be overridden to use a simpler
  107. * layout, or one can set default values shared by all columns:
  108. *
  109. * columns: {
  110. * items: [
  111. * {
  112. * text: &quot;Column A&quot;
  113. * dataIndex: &quot;field_A&quot;
  114. * },{
  115. * text: &quot;Column B&quot;,
  116. * dataIndex: &quot;field_B&quot;
  117. * },
  118. * ...
  119. * ],
  120. * defaults: {
  121. * flex: 1
  122. * }
  123. * }
  124. */
  125. <span id='Ext-panel-Table-cfg-forceFit'> /**
  126. </span> * @cfg {Boolean} forceFit
  127. * Ttrue to force the columns to fit into the available width. Headers are first sized according to configuration,
  128. * whether that be a specific width, or flex. Then they are all proportionally changed in width so that the entire
  129. * content width is used. For more accurate control, it is more optimal to specify a flex setting on the columns
  130. * that are to be stretched &amp; explicit widths on columns that are not.
  131. */
  132. <span id='Ext-panel-Table-cfg-features'> /**
  133. </span> * @cfg {Ext.grid.feature.Feature[]} features
  134. * An array of grid Features to be added to this grid. See {@link Ext.grid.feature.Feature} for usage.
  135. */
  136. <span id='Ext-panel-Table-cfg-hideHeaders'> /**
  137. </span> * @cfg {Boolean} [hideHeaders=false]
  138. * True to hide column headers.
  139. */
  140. <span id='Ext-panel-Table-cfg-deferRowRender'> /**
  141. </span> * @cfg {Boolean} deferRowRender
  142. * Defaults to true to enable deferred row rendering.
  143. *
  144. * This allows the View to execute a refresh quickly, with the expensive update of the row structure deferred so
  145. * that layouts with GridPanels appear, and lay out more quickly.
  146. */
  147. <span id='Ext-panel-Table-cfg-verticalScroller'> /**
  148. </span> * @cfg {Object} verticalScroller
  149. * A config object to be used when configuring the {@link Ext.grid.PagingScroller scroll monitor} to control
  150. * refreshing of data in an &quot;infinite grid&quot;.
  151. *
  152. * Configurations of this object allow fine tuning of data caching which can improve performance and usability
  153. * of the infinite grid.
  154. */
  155. deferRowRender: true,
  156. <span id='Ext-panel-Table-cfg-sortableColumns'> /**
  157. </span> * @cfg {Boolean} sortableColumns
  158. * False to disable column sorting via clicking the header and via the Sorting menu items.
  159. */
  160. sortableColumns: true,
  161. <span id='Ext-panel-Table-cfg-enableLocking'> /**
  162. </span> * @cfg {Boolean} [enableLocking=false]
  163. * True to enable locking support for this grid. Alternatively, locking will also be automatically
  164. * enabled if any of the columns in the column configuration contain the locked config option.
  165. */
  166. enableLocking: false,
  167. // private property used to determine where to go down to find views
  168. // this is here to support locking.
  169. scrollerOwner: true,
  170. <span id='Ext-panel-Table-cfg-enableColumnMove'> /**
  171. </span> * @cfg {Boolean} [enableColumnMove=true]
  172. * False to disable column dragging within this grid.
  173. */
  174. enableColumnMove: true,
  175. <span id='Ext-panel-Table-cfg-sealedColumns'> /**
  176. </span> * @cfg {Boolean} [sealedColumns=false]
  177. * True to constrain column dragging so that a column cannot be dragged in or out of it's
  178. * current group. Only relevant while {@link #enableColumnMove} is enabled.
  179. */
  180. sealedColumns: false,
  181. <span id='Ext-panel-Table-cfg-enableColumnResize'> /**
  182. </span> * @cfg {Boolean} [enableColumnResize=true]
  183. * False to disable column resizing within this grid.
  184. */
  185. enableColumnResize: true,
  186. <span id='Ext-panel-Table-cfg-enableColumnHide'> /**
  187. </span> * @cfg {Boolean} [enableColumnHide=true]
  188. * False to disable column hiding within this grid.
  189. */
  190. enableColumnHide: true,
  191. <span id='Ext-panel-Table-cfg-columnLines'> /**
  192. </span> * @cfg {Boolean} columnLines Adds column line styling
  193. */
  194. <span id='Ext-panel-Table-cfg-rowLines'> /**
  195. </span> * @cfg {Boolean} [rowLines=true] Adds row line styling
  196. */
  197. rowLines: true,
  198. <span id='Ext-panel-Table-cfg-disableSelection'> /**
  199. </span> * @cfg {Boolean} [disableSelection=false]
  200. * True to disable selection model.
  201. */
  202. <span id='Ext-panel-Table-cfg-emptyText'> /**
  203. </span> * @cfg {String} emptyText Default text (html tags are accepted) to display in the Panel body when the Store
  204. * is empty. When specified, and the Store is empty, the text will be rendered inside a DIV with the CSS class &quot;x-grid-empty&quot;.
  205. */
  206. <span id='Ext-panel-Table-cfg-allowDeselect'> /**
  207. </span> * @cfg {Boolean} [allowDeselect=false]
  208. * True to allow deselecting a record. This config is forwarded to {@link Ext.selection.Model#allowDeselect}.
  209. */
  210. <span id='Ext-panel-Table-property-optimizedColumnMove'> /**
  211. </span> * @property {Boolean} optimizedColumnMove
  212. * If you are writing a grid plugin or a {Ext.grid.feature.Feature Feature} which creates a column-based structure which
  213. * needs a view refresh when columns are moved, then set this property in the grid.
  214. *
  215. * An example is the built in {@link Ext.grid.feature.AbstractSummary Summary} Feature. This creates summary rows, and the
  216. * summary columns must be in the same order as the data columns. This plugin sets the `optimizedColumnMove` to `false.
  217. */
  218. initComponent: function() {
  219. //&lt;debug&gt;
  220. if (!this.viewType) {
  221. Ext.Error.raise(&quot;You must specify a viewType config.&quot;);
  222. }
  223. if (this.headers) {
  224. Ext.Error.raise(&quot;The headers config is not supported. Please specify columns instead.&quot;);
  225. }
  226. //&lt;/debug&gt;
  227. var me = this,
  228. scroll = me.scroll,
  229. vertical = false,
  230. horizontal = false,
  231. headerCtCfg = me.columns || me.colModel,
  232. view,
  233. border = me.border,
  234. i, len;
  235. if (me.columnLines) {
  236. me.addCls(Ext.baseCSSPrefix + 'grid-with-col-lines');
  237. }
  238. if (me.rowLines) {
  239. me.addCls(Ext.baseCSSPrefix + 'grid-with-row-lines');
  240. }
  241. // Look up the configured Store. If none configured, use the fieldless, empty Store defined in Ext.data.Store.
  242. me.store = Ext.data.StoreManager.lookup(me.store || 'ext-empty-store');
  243. //&lt;debug&gt;
  244. if (!headerCtCfg) {
  245. Ext.Error.raise(&quot;A column configuration must be specified&quot;);
  246. }
  247. //&lt;/debug&gt;
  248. // The columns/colModel config may be either a fully instantiated HeaderContainer, or an array of Column definitions, or a config object of a HeaderContainer
  249. // Either way, we extract a columns property referencing an array of Column definitions.
  250. if (headerCtCfg instanceof Ext.grid.header.Container) {
  251. me.headerCt = headerCtCfg;
  252. me.headerCt.border = border;
  253. me.columns = me.headerCt.items.items;
  254. } else {
  255. if (Ext.isArray(headerCtCfg)) {
  256. headerCtCfg = {
  257. items: headerCtCfg,
  258. border: border
  259. };
  260. }
  261. Ext.apply(headerCtCfg, {
  262. forceFit: me.forceFit,
  263. sortable: me.sortableColumns,
  264. enableColumnMove: me.enableColumnMove,
  265. enableColumnResize: me.enableColumnResize,
  266. enableColumnHide: me.enableColumnHide,
  267. border: border,
  268. sealed: me.sealedColumns
  269. });
  270. me.columns = headerCtCfg.items;
  271. // If any of the Column objects contain a locked property, and are not processed, this is a lockable TablePanel, a
  272. // special view will be injected by the Ext.grid.Lockable mixin, so no processing of .
  273. if (me.enableLocking || Ext.ComponentQuery.query('{locked !== undefined}{processed != true}', me.columns).length) {
  274. me.self.mixin('lockable', Ext.grid.Lockable);
  275. me.injectLockable();
  276. }
  277. }
  278. me.scrollTask = new Ext.util.DelayedTask(me.syncHorizontalScroll, me);
  279. me.addEvents(
  280. // documented on GridPanel
  281. 'reconfigure',
  282. <span id='Ext-panel-Table-event-viewready'> /**
  283. </span> * @event viewready
  284. * Fires when the grid view is available (use this for selecting a default row).
  285. * @param {Ext.panel.Table} this
  286. */
  287. 'viewready'
  288. );
  289. me.bodyCls = me.bodyCls || '';
  290. me.bodyCls += (' ' + me.extraBodyCls);
  291. me.cls = me.cls || '';
  292. me.cls += (' ' + me.extraBaseCls);
  293. // autoScroll is not a valid configuration
  294. delete me.autoScroll;
  295. // If this TablePanel is lockable (Either configured lockable, or any of the defined columns has a 'locked' property)
  296. // than a special lockable view containing 2 side-by-side grids will have been injected so we do not need to set up any UI.
  297. if (!me.hasView) {
  298. // If we were not configured with a ready-made headerCt (either by direct config with a headerCt property, or by passing
  299. // a HeaderContainer instance as the 'columns' property, then go ahead and create one from the config object created above.
  300. if (!me.headerCt) {
  301. me.headerCt = new Ext.grid.header.Container(headerCtCfg);
  302. }
  303. // Extract the array of Column objects
  304. me.columns = me.headerCt.items.items;
  305. // If the Store is paging blocks of the dataset in, then it can only be sorted remotely.
  306. if (me.store.buffered &amp;&amp; !me.store.remoteSort) {
  307. for (i = 0, len = me.columns.length; i &lt; len; i++) {
  308. me.columns[i].sortable = false;
  309. }
  310. }
  311. if (me.hideHeaders) {
  312. me.headerCt.height = 0;
  313. me.headerCt.addCls(Ext.baseCSSPrefix + 'grid-header-ct-hidden');
  314. me.addCls(Ext.baseCSSPrefix + 'grid-header-hidden');
  315. // IE Quirks Mode fix
  316. // If hidden configuration option was used, several layout calculations will be bypassed.
  317. if (Ext.isIEQuirks) {
  318. me.headerCt.style = {
  319. display: 'none'
  320. };
  321. }
  322. }
  323. // turn both on.
  324. if (scroll === true || scroll === 'both') {
  325. vertical = horizontal = true;
  326. } else if (scroll === 'horizontal') {
  327. horizontal = true;
  328. } else if (scroll === 'vertical') {
  329. vertical = true;
  330. }
  331. me.relayHeaderCtEvents(me.headerCt);
  332. me.features = me.features || [];
  333. if (!Ext.isArray(me.features)) {
  334. me.features = [me.features];
  335. }
  336. me.dockedItems = [].concat(me.dockedItems || []);
  337. me.dockedItems.unshift(me.headerCt);
  338. me.viewConfig = me.viewConfig || {};
  339. // Buffered scrolling must preserve scroll on refresh
  340. if (me.store &amp;&amp; me.store.buffered) {
  341. me.viewConfig.preserveScrollOnRefresh = true;
  342. } else if (me.invalidateScrollerOnRefresh !== undefined) {
  343. me.viewConfig.preserveScrollOnRefresh = !me.invalidateScrollerOnRefresh;
  344. }
  345. // AbstractDataView will look up a Store configured as an object
  346. // getView converts viewConfig into a View instance
  347. view = me.getView();
  348. me.items = [view];
  349. me.hasView = true;
  350. if (vertical) {
  351. // If the Store is buffered, create a PagingScroller to monitor the View's scroll progress,
  352. // load the Store's prefetch buffer when it detects we are nearing an edge.
  353. if (me.store.buffered) {
  354. me.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({
  355. panel: me,
  356. store: me.store,
  357. view: me.view
  358. }, me.verticalScroller));
  359. }
  360. }
  361. if (horizontal) {
  362. // Add a listener to synchronize the horizontal scroll position of the headers
  363. // with the table view's element... Unless we are not showing headers!
  364. if (!me.hideHeaders) {
  365. view.on({
  366. scroll: {
  367. fn: me.onHorizontalScroll,
  368. element: 'el',
  369. scope: me
  370. }
  371. });
  372. }
  373. }
  374. me.mon(view.store, {
  375. load: me.onStoreLoad,
  376. scope: me
  377. });
  378. me.mon(view, {
  379. viewready: me.onViewReady,
  380. refresh: me.onRestoreHorzScroll,
  381. scope: me
  382. });
  383. }
  384. // Relay events from the View whether it be a LockingView, or a regular GridView
  385. this.relayEvents(me.view, [
  386. <span id='Ext-panel-Table-event-beforeitemmousedown'> /**
  387. </span> * @event beforeitemmousedown
  388. * @inheritdoc Ext.view.View#beforeitemmousedown
  389. */
  390. 'beforeitemmousedown',
  391. <span id='Ext-panel-Table-event-beforeitemmouseup'> /**
  392. </span> * @event beforeitemmouseup
  393. * @inheritdoc Ext.view.View#beforeitemmouseup
  394. */
  395. 'beforeitemmouseup',
  396. <span id='Ext-panel-Table-event-beforeitemmouseenter'> /**
  397. </span> * @event beforeitemmouseenter
  398. * @inheritdoc Ext.view.View#beforeitemmouseenter
  399. */
  400. 'beforeitemmouseenter',
  401. <span id='Ext-panel-Table-event-beforeitemmouseleave'> /**
  402. </span> * @event beforeitemmouseleave
  403. * @inheritdoc Ext.view.View#beforeitemmouseleave
  404. */
  405. 'beforeitemmouseleave',
  406. <span id='Ext-panel-Table-event-beforeitemclick'> /**
  407. </span> * @event beforeitemclick
  408. * @inheritdoc Ext.view.View#beforeitemclick
  409. */
  410. 'beforeitemclick',
  411. <span id='Ext-panel-Table-event-beforeitemdblclick'> /**
  412. </span> * @event beforeitemdblclick
  413. * @inheritdoc Ext.view.View#beforeitemdblclick
  414. */
  415. 'beforeitemdblclick',
  416. <span id='Ext-panel-Table-event-beforeitemcontextmenu'> /**
  417. </span> * @event beforeitemcontextmenu
  418. * @inheritdoc Ext.view.View#beforeitemcontextmenu
  419. */
  420. 'beforeitemcontextmenu',
  421. <span id='Ext-panel-Table-event-itemmousedown'> /**
  422. </span> * @event itemmousedown
  423. * @inheritdoc Ext.view.View#itemmousedown
  424. */
  425. 'itemmousedown',
  426. <span id='Ext-panel-Table-event-itemmouseup'> /**
  427. </span> * @event itemmouseup
  428. * @inheritdoc Ext.view.View#itemmouseup
  429. */
  430. 'itemmouseup',
  431. <span id='Ext-panel-Table-event-itemmouseenter'> /**
  432. </span> * @event itemmouseenter
  433. * @inheritdoc Ext.view.View#itemmouseenter
  434. */
  435. 'itemmouseenter',
  436. <span id='Ext-panel-Table-event-itemmouseleave'> /**
  437. </span> * @event itemmouseleave
  438. * @inheritdoc Ext.view.View#itemmouseleave
  439. */
  440. 'itemmouseleave',
  441. <span id='Ext-panel-Table-event-itemclick'> /**
  442. </span> * @event itemclick
  443. * @inheritdoc Ext.view.View#itemclick
  444. */
  445. 'itemclick',
  446. <span id='Ext-panel-Table-event-itemdblclick'> /**
  447. </span> * @event itemdblclick
  448. * @inheritdoc Ext.view.View#itemdblclick
  449. */
  450. 'itemdblclick',
  451. <span id='Ext-panel-Table-event-itemcontextmenu'> /**
  452. </span> * @event itemcontextmenu
  453. * @inheritdoc Ext.view.View#itemcontextmenu
  454. */
  455. 'itemcontextmenu',
  456. <span id='Ext-panel-Table-event-beforecontainermousedown'> /**
  457. </span> * @event beforecontainermousedown
  458. * @inheritdoc Ext.view.View#beforecontainermousedown
  459. */
  460. 'beforecontainermousedown',
  461. <span id='Ext-panel-Table-event-beforecontainermouseup'> /**
  462. </span> * @event beforecontainermouseup
  463. * @inheritdoc Ext.view.View#beforecontainermouseup
  464. */
  465. 'beforecontainermouseup',
  466. <span id='Ext-panel-Table-event-beforecontainermouseover'> /**
  467. </span> * @event beforecontainermouseover
  468. * @inheritdoc Ext.view.View#beforecontainermouseover
  469. */
  470. 'beforecontainermouseover',
  471. <span id='Ext-panel-Table-event-beforecontainermouseout'> /**
  472. </span> * @event beforecontainermouseout
  473. * @inheritdoc Ext.view.View#beforecontainermouseout
  474. */
  475. 'beforecontainermouseout',
  476. <span id='Ext-panel-Table-event-beforecontainerclick'> /**
  477. </span> * @event beforecontainerclick
  478. * @inheritdoc Ext.view.View#beforecontainerclick
  479. */
  480. 'beforecontainerclick',
  481. <span id='Ext-panel-Table-event-beforecontainerdblclick'> /**
  482. </span> * @event beforecontainerdblclick
  483. * @inheritdoc Ext.view.View#beforecontainerdblclick
  484. */
  485. 'beforecontainerdblclick',
  486. <span id='Ext-panel-Table-event-beforecontainercontextmenu'> /**
  487. </span> * @event beforecontainercontextmenu
  488. * @inheritdoc Ext.view.View#beforecontainercontextmenu
  489. */
  490. 'beforecontainercontextmenu',
  491. <span id='Ext-panel-Table-event-containermouseup'> /**
  492. </span> * @event containermouseup
  493. * @inheritdoc Ext.view.View#containermouseup
  494. */
  495. 'containermouseup',
  496. <span id='Ext-panel-Table-event-containermouseover'> /**
  497. </span> * @event containermouseover
  498. * @inheritdoc Ext.view.View#containermouseover
  499. */
  500. 'containermouseover',
  501. <span id='Ext-panel-Table-event-containermouseout'> /**
  502. </span> * @event containermouseout
  503. * @inheritdoc Ext.view.View#containermouseout
  504. */
  505. 'containermouseout',
  506. <span id='Ext-panel-Table-event-containerclick'> /**
  507. </span> * @event containerclick
  508. * @inheritdoc Ext.view.View#containerclick
  509. */
  510. 'containerclick',
  511. <span id='Ext-panel-Table-event-containerdblclick'> /**
  512. </span> * @event containerdblclick
  513. * @inheritdoc Ext.view.View#containerdblclick
  514. */
  515. 'containerdblclick',
  516. <span id='Ext-panel-Table-event-containercontextmenu'> /**
  517. </span> * @event containercontextmenu
  518. * @inheritdoc Ext.view.View#containercontextmenu
  519. */
  520. 'containercontextmenu',
  521. <span id='Ext-panel-Table-event-selectionchange'> /**
  522. </span> * @event selectionchange
  523. * @inheritdoc Ext.selection.Model#selectionchange
  524. */
  525. 'selectionchange',
  526. <span id='Ext-panel-Table-event-beforeselect'> /**
  527. </span> * @event beforeselect
  528. * @inheritdoc Ext.selection.RowModel#beforeselect
  529. */
  530. 'beforeselect',
  531. <span id='Ext-panel-Table-event-select'> /**
  532. </span> * @event select
  533. * @inheritdoc Ext.selection.RowModel#select
  534. */
  535. 'select',
  536. <span id='Ext-panel-Table-event-beforedeselect'> /**
  537. </span> * @event beforedeselect
  538. * @inheritdoc Ext.selection.RowModel#beforedeselect
  539. */
  540. 'beforedeselect',
  541. <span id='Ext-panel-Table-event-deselect'> /**
  542. </span> * @event deselect
  543. * @inheritdoc Ext.selection.RowModel#deselect
  544. */
  545. 'deselect'
  546. ]);
  547. me.callParent(arguments);
  548. me.addStateEvents(['columnresize', 'columnmove', 'columnhide', 'columnshow', 'sortchange']);
  549. if (me.headerCt) {
  550. me.headerCt.on('afterlayout', me.onRestoreHorzScroll, me);
  551. }
  552. },
  553. relayHeaderCtEvents: function (headerCt) {
  554. this.relayEvents(headerCt, [
  555. <span id='Ext-panel-Table-event-columnresize'> /**
  556. </span> * @event columnresize
  557. * @inheritdoc Ext.grid.header.Container#columnresize
  558. */
  559. 'columnresize',
  560. <span id='Ext-panel-Table-event-columnmove'> /**
  561. </span> * @event columnmove
  562. * @inheritdoc Ext.grid.header.Container#columnmove
  563. */
  564. 'columnmove',
  565. <span id='Ext-panel-Table-event-columnhide'> /**
  566. </span> * @event columnhide
  567. * @inheritdoc Ext.grid.header.Container#columnhide
  568. */
  569. 'columnhide',
  570. <span id='Ext-panel-Table-event-columnshow'> /**
  571. </span> * @event columnshow
  572. * @inheritdoc Ext.grid.header.Container#columnshow
  573. */
  574. 'columnshow',
  575. <span id='Ext-panel-Table-event-sortchange'> /**
  576. </span> * @event sortchange
  577. * @inheritdoc Ext.grid.header.Container#sortchange
  578. */
  579. 'sortchange'
  580. ]);
  581. },
  582. getState: function(){
  583. var me = this,
  584. state = me.callParent(),
  585. sorter = me.store.sorters.first();
  586. state = me.addPropertyToState(state, 'columns', (me.headerCt || me).getColumnsState());
  587. if (sorter) {
  588. state = me.addPropertyToState(state, 'sort', {
  589. property: sorter.property,
  590. direction: sorter.direction,
  591. root: sorter.root
  592. });
  593. }
  594. return state;
  595. },
  596. applyState: function(state) {
  597. var me = this,
  598. sorter = state.sort,
  599. store = me.store,
  600. columns = state.columns;
  601. delete state.columns;
  602. // Ensure superclass has applied *its* state.
  603. // AbstractComponent saves dimensions (and anchor/flex) plus collapsed state.
  604. me.callParent(arguments);
  605. if (columns) {
  606. (me.headerCt || me).applyColumnsState(columns);
  607. }
  608. if (sorter) {
  609. if (store.remoteSort) {
  610. // Pass false to prevent a sort from occurring
  611. store.sort({
  612. property: sorter.property,
  613. direction: sorter.direction,
  614. root: sorter.root
  615. }, null, false);
  616. } else {
  617. store.sort(sorter.property, sorter.direction);
  618. }
  619. }
  620. },
  621. <span id='Ext-panel-Table-method-getStore'> /**
  622. </span> * Returns the store associated with this Panel.
  623. * @return {Ext.data.Store} The store
  624. */
  625. getStore: function(){
  626. return this.store;
  627. },
  628. <span id='Ext-panel-Table-method-getView'> /**
  629. </span> * Gets the view for this panel.
  630. * @return {Ext.view.Table}
  631. */
  632. getView: function() {
  633. var me = this,
  634. sm;
  635. if (!me.view) {
  636. sm = me.getSelectionModel();
  637. me.view = Ext.widget(Ext.apply({}, me.viewConfig, {
  638. // Features need a reference to the grid, so configure a reference into the View
  639. grid: me,
  640. deferInitialRefresh: me.deferRowRender !== false,
  641. scroll: me.scroll,
  642. xtype: me.viewType,
  643. store: me.store,
  644. headerCt: me.headerCt,
  645. selModel: sm,
  646. features: me.features,
  647. panel: me,
  648. emptyText : me.emptyText ? '&lt;div class=&quot;' + Ext.baseCSSPrefix + 'grid-empty&quot;&gt;' + me.emptyText + '&lt;/div&gt;' : ''
  649. }));
  650. // TableView's custom component layout, Ext.view.TableLayout requires a reference to the headerCt because it depends on the headerCt doing its work.
  651. me.view.getComponentLayout().headerCt = me.headerCt;
  652. me.mon(me.view, {
  653. uievent: me.processEvent,
  654. scope: me
  655. });
  656. sm.view = me.view;
  657. me.headerCt.view = me.view;
  658. me.relayEvents(me.view, [
  659. <span id='Ext-panel-Table-event-cellclick'> /**
  660. </span> * @event cellclick
  661. * Fired when table cell is clicked.
  662. * @param {Ext.view.Table} this
  663. * @param {HTMLElement} td The TD element that was clicked.
  664. * @param {Number} cellIndex
  665. * @param {Ext.data.Model} record
  666. * @param {HTMLElement} tr The TR element that was clicked.
  667. * @param {Number} rowIndex
  668. * @param {Ext.EventObject} e
  669. */
  670. 'cellclick',
  671. <span id='Ext-panel-Table-event-celldblclick'> /**
  672. </span> * @event celldblclick
  673. * Fired when table cell is double clicked.
  674. * @param {Ext.view.Table} this
  675. * @param {HTMLElement} td The TD element that was clicked.
  676. * @param {Number} cellIndex
  677. * @param {Ext.data.Model} record
  678. * @param {HTMLElement} tr The TR element that was clicked.
  679. * @param {Number} rowIndex
  680. * @param {Ext.EventObject} e
  681. */
  682. 'celldblclick'
  683. ]);
  684. }
  685. return me.view;
  686. },
  687. <span id='Ext-panel-Table-method-setAutoScroll'> /**
  688. </span> * @private
  689. * autoScroll is never valid for all classes which extend TablePanel.
  690. */
  691. setAutoScroll: Ext.emptyFn,
  692. <span id='Ext-panel-Table-method-processEvent'> /**
  693. </span> * @private
  694. * Processes UI events from the view. Propagates them to whatever internal Components need to process them.
  695. * @param {String} type Event type, eg 'click'
  696. * @param {Ext.view.Table} view TableView Component
  697. * @param {HTMLElement} cell Cell HtmlElement the event took place within
  698. * @param {Number} recordIndex Index of the associated Store Model (-1 if none)
  699. * @param {Number} cellIndex Cell index within the row
  700. * @param {Ext.EventObject} e Original event
  701. */
  702. processEvent: function(type, view, cell, recordIndex, cellIndex, e) {
  703. var me = this,
  704. header;
  705. if (cellIndex !== -1) {
  706. header = me.headerCt.getGridColumns()[cellIndex];
  707. return header.processEvent.apply(header, arguments);
  708. }
  709. },
  710. <span id='Ext-panel-Table-method-determineScrollbars'> /**
  711. </span> * This method is obsolete in 4.1. The closest equivalent in
  712. * 4.1 is {@link #doLayout}, but it is also possible that no
  713. * layout is needed.
  714. * @deprecated 4.1
  715. */
  716. determineScrollbars: function () {
  717. //&lt;debug&gt;
  718. Ext.log.warn('Obsolete');
  719. //&lt;/debug&gt;
  720. },
  721. <span id='Ext-panel-Table-method-invalidateScroller'> /**
  722. </span> * This method is obsolete in 4.1. The closest equivalent in 4.1 is
  723. * {@link Ext.AbstractComponent#updateLayout}, but it is also possible that no layout
  724. * is needed.
  725. * @deprecated 4.1
  726. */
  727. invalidateScroller: function () {
  728. //&lt;debug&gt;
  729. Ext.log.warn('Obsolete');
  730. //&lt;/debug&gt;
  731. },
  732. scrollByDeltaY: function(yDelta, animate) {
  733. this.getView().scrollBy(0, yDelta, animate);
  734. },
  735. scrollByDeltaX: function(xDelta, animate) {
  736. this.getView().scrollBy(xDelta, 0, animate);
  737. },
  738. afterCollapse: function() {
  739. var me = this;
  740. me.saveScrollPos();
  741. me.saveScrollPos();
  742. me.callParent(arguments);
  743. },
  744. afterExpand: function() {
  745. var me = this;
  746. me.callParent(arguments);
  747. me.restoreScrollPos();
  748. me.restoreScrollPos();
  749. },
  750. saveScrollPos: Ext.emptyFn,
  751. restoreScrollPos: Ext.emptyFn,
  752. onHeaderResize: function(){
  753. this.delayScroll();
  754. },
  755. // Update the view when a header moves
  756. onHeaderMove: function(headerCt, header, colsToMove, fromIdx, toIdx) {
  757. var me = this;
  758. // If there are Features or Plugins which create DOM which must match column order, they set the optimizedColumnMove flag to false.
  759. // In this case we must refresh the view on column move.
  760. if (me.optimizedColumnMove === false) {
  761. me.view.refresh();
  762. }
  763. // Simplest case for default DOM structure is just to swap the columns round in the view.
  764. else {
  765. me.view.moveColumn(fromIdx, toIdx, colsToMove);
  766. }
  767. me.delayScroll();
  768. },
  769. // Section onHeaderHide is invoked after view.
  770. onHeaderHide: function(headerCt, header) {
  771. this.delayScroll();
  772. },
  773. onHeaderShow: function(headerCt, header) {
  774. this.delayScroll();
  775. },
  776. delayScroll: function(){
  777. var target = this.getScrollTarget().el;
  778. if (target) {
  779. this.scrollTask.delay(10, null, null, [target.dom.scrollLeft]);
  780. }
  781. },
  782. <span id='Ext-panel-Table-method-onViewReady'> /**
  783. </span> * @private
  784. * Fires the TablePanel's viewready event when the view declares that its internal DOM is ready
  785. */
  786. onViewReady: function() {
  787. this.fireEvent('viewready', this);
  788. },
  789. <span id='Ext-panel-Table-method-onRestoreHorzScroll'> /**
  790. </span> * @private
  791. * Tracks when things happen to the view and preserves the horizontal scroll position.
  792. */
  793. onRestoreHorzScroll: function() {
  794. var left = this.scrollLeftPos;
  795. if (left) {
  796. // We need to restore the body scroll position here
  797. this.syncHorizontalScroll(left, true);
  798. }
  799. },
  800. getScrollerOwner: function() {
  801. var rootCmp = this;
  802. if (!this.scrollerOwner) {
  803. rootCmp = this.up('[scrollerOwner]');
  804. }
  805. return rootCmp;
  806. },
  807. <span id='Ext-panel-Table-method-getLhsMarker'> /**
  808. </span> * Gets left hand side marker for header resizing.
  809. * @private
  810. */
  811. getLhsMarker: function() {
  812. var me = this;
  813. return me.lhsMarker || (me.lhsMarker = Ext.DomHelper.append(me.el, {
  814. cls: Ext.baseCSSPrefix + 'grid-resize-marker'
  815. }, true));
  816. },
  817. <span id='Ext-panel-Table-method-getRhsMarker'> /**
  818. </span> * Gets right hand side marker for header resizing.
  819. * @private
  820. */
  821. getRhsMarker: function() {
  822. var me = this;
  823. return me.rhsMarker || (me.rhsMarker = Ext.DomHelper.append(me.el, {
  824. cls: Ext.baseCSSPrefix + 'grid-resize-marker'
  825. }, true));
  826. },
  827. <span id='Ext-panel-Table-method-getSelectionModel'> /**
  828. </span> * Returns the selection model being used and creates it via the configuration if it has not been created already.
  829. * @return {Ext.selection.Model} selModel
  830. */
  831. getSelectionModel: function(){
  832. if (!this.selModel) {
  833. this.selModel = {};
  834. }
  835. var mode = 'SINGLE',
  836. type;
  837. if (this.simpleSelect) {
  838. mode = 'SIMPLE';
  839. } else if (this.multiSelect) {
  840. mode = 'MULTI';
  841. }
  842. Ext.applyIf(this.selModel, {
  843. allowDeselect: this.allowDeselect,
  844. mode: mode
  845. });
  846. if (!this.selModel.events) {
  847. type = this.selModel.selType || this.selType;
  848. this.selModel = Ext.create('selection.' + type, this.selModel);
  849. }
  850. if (!this.selModel.hasRelaySetup) {
  851. this.relayEvents(this.selModel, [
  852. 'selectionchange', 'beforeselect', 'beforedeselect', 'select', 'deselect'
  853. ]);
  854. this.selModel.hasRelaySetup = true;
  855. }
  856. // lock the selection model if user
  857. // has disabled selection
  858. if (this.disableSelection) {
  859. this.selModel.locked = true;
  860. }
  861. return this.selModel;
  862. },
  863. getScrollTarget: function(){
  864. var owner = this.getScrollerOwner(),
  865. items = owner.query('tableview');
  866. return items[1] || items[0];
  867. },
  868. onHorizontalScroll: function(event, target) {
  869. this.syncHorizontalScroll(target.scrollLeft);
  870. },
  871. syncHorizontalScroll: function(left, setBody) {
  872. var me = this,
  873. scrollTarget;
  874. setBody = setBody === true;
  875. // Only set the horizontal scroll if we've changed position,
  876. // so that we don't set this on vertical scrolls
  877. if (me.rendered &amp;&amp; (setBody || left !== me.scrollLeftPos)) {
  878. // Only set the body position if we're reacting to a refresh, otherwise
  879. // we just need to set the header.
  880. if (setBody) {
  881. scrollTarget = me.getScrollTarget();
  882. scrollTarget.el.dom.scrollLeft = left;
  883. }
  884. me.headerCt.el.dom.scrollLeft = left;
  885. me.scrollLeftPos = left;
  886. }
  887. },
  888. // template method meant to be overriden
  889. onStoreLoad: Ext.emptyFn,
  890. getEditorParent: function() {
  891. return this.body;
  892. },
  893. bindStore: function(store) {
  894. var me = this;
  895. me.store = store;
  896. me.getView().bindStore(store);
  897. },
  898. beforeDestroy: function(){
  899. Ext.destroy(this.verticalScroller);
  900. this.callParent();
  901. },
  902. // documented on GridPanel
  903. reconfigure: function(store, columns) {
  904. var me = this,
  905. headerCt = me.headerCt;
  906. if (me.lockable) {
  907. me.reconfigureLockable(store, columns);
  908. } else {
  909. Ext.suspendLayouts();
  910. if (columns) {
  911. // new columns, delete scroll pos
  912. delete me.scrollLeftPos;
  913. headerCt.removeAll();
  914. headerCt.add(columns);
  915. }
  916. if (store) {
  917. store = Ext.StoreManager.lookup(store);
  918. me.bindStore(store);
  919. } else {
  920. me.getView().refresh();
  921. }
  922. headerCt.setSortState();
  923. Ext.resumeLayouts(true);
  924. }
  925. me.fireEvent('reconfigure', me, store, columns);
  926. }
  927. });
  928. </pre>
  929. </body>
  930. </html>