Panel3.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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-grid-Panel'>/**
  19. </span> * @author Aaron Conran
  20. * @docauthor Ed Spencer
  21. *
  22. * Grids are an excellent way of showing large amounts of tabular data on the client side. Essentially a supercharged
  23. * `&lt;table&gt;`, GridPanel makes it easy to fetch, sort and filter large amounts of data.
  24. *
  25. * Grids are composed of two main pieces - a {@link Ext.data.Store Store} full of data and a set of columns to render.
  26. *
  27. * ## Basic GridPanel
  28. *
  29. * @example
  30. * Ext.create('Ext.data.Store', {
  31. * storeId:'simpsonsStore',
  32. * fields:['name', 'email', 'phone'],
  33. * data:{'items':[
  34. * { 'name': 'Lisa', &quot;email&quot;:&quot;lisa@simpsons.com&quot;, &quot;phone&quot;:&quot;555-111-1224&quot; },
  35. * { 'name': 'Bart', &quot;email&quot;:&quot;bart@simpsons.com&quot;, &quot;phone&quot;:&quot;555-222-1234&quot; },
  36. * { 'name': 'Homer', &quot;email&quot;:&quot;home@simpsons.com&quot;, &quot;phone&quot;:&quot;555-222-1244&quot; },
  37. * { 'name': 'Marge', &quot;email&quot;:&quot;marge@simpsons.com&quot;, &quot;phone&quot;:&quot;555-222-1254&quot; }
  38. * ]},
  39. * proxy: {
  40. * type: 'memory',
  41. * reader: {
  42. * type: 'json',
  43. * root: 'items'
  44. * }
  45. * }
  46. * });
  47. *
  48. * Ext.create('Ext.grid.Panel', {
  49. * title: 'Simpsons',
  50. * store: Ext.data.StoreManager.lookup('simpsonsStore'),
  51. * columns: [
  52. * { text: 'Name', dataIndex: 'name' },
  53. * { text: 'Email', dataIndex: 'email', flex: 1 },
  54. * { text: 'Phone', dataIndex: 'phone' }
  55. * ],
  56. * height: 200,
  57. * width: 400,
  58. * renderTo: Ext.getBody()
  59. * });
  60. *
  61. * The code above produces a simple grid with three columns. We specified a Store which will load JSON data inline.
  62. * In most apps we would be placing the grid inside another container and wouldn't need to use the
  63. * {@link #height}, {@link #width} and {@link #renderTo} configurations but they are included here to make it easy to get
  64. * up and running.
  65. *
  66. * The grid we created above will contain a header bar with a title ('Simpsons'), a row of column headers directly underneath
  67. * and finally the grid rows under the headers.
  68. *
  69. * ## Configuring columns
  70. *
  71. * By default, each column is sortable and will toggle between ASC and DESC sorting when you click on its header. Each
  72. * column header is also reorderable by default, and each gains a drop-down menu with options to hide and show columns.
  73. * It's easy to configure each column - here we use the same example as above and just modify the columns config:
  74. *
  75. * columns: [
  76. * {
  77. * text: 'Name',
  78. * dataIndex: 'name',
  79. * sortable: false,
  80. * hideable: false,
  81. * flex: 1
  82. * },
  83. * {
  84. * text: 'Email',
  85. * dataIndex: 'email',
  86. * hidden: true
  87. * },
  88. * {
  89. * text: 'Phone',
  90. * dataIndex: 'phone',
  91. * width: 100
  92. * }
  93. * ]
  94. *
  95. * We turned off sorting and hiding on the 'Name' column so clicking its header now has no effect. We also made the Email
  96. * column hidden by default (it can be shown again by using the menu on any other column). We also set the Phone column to
  97. * a fixed with of 100px and flexed the Name column, which means it takes up all remaining width after the other columns
  98. * have been accounted for. See the {@link Ext.grid.column.Column column docs} for more details.
  99. *
  100. * ## Renderers
  101. *
  102. * As well as customizing columns, it's easy to alter the rendering of individual cells using renderers. A renderer is
  103. * tied to a particular column and is passed the value that would be rendered into each cell in that column. For example,
  104. * we could define a renderer function for the email column to turn each email address into a mailto link:
  105. *
  106. * columns: [
  107. * {
  108. * text: 'Email',
  109. * dataIndex: 'email',
  110. * renderer: function(value) {
  111. * return Ext.String.format('&lt;a href=&quot;mailto:{0}&quot;&gt;{1}&lt;/a&gt;', value, value);
  112. * }
  113. * }
  114. * ]
  115. *
  116. * See the {@link Ext.grid.column.Column column docs} for more information on renderers.
  117. *
  118. * ## Selection Models
  119. *
  120. * Sometimes all you want is to render data onto the screen for viewing, but usually it's necessary to interact with or
  121. * update that data. Grids use a concept called a Selection Model, which is simply a mechanism for selecting some part of
  122. * the data in the grid. The two main types of Selection Model are RowSelectionModel, where entire rows are selected, and
  123. * CellSelectionModel, where individual cells are selected.
  124. *
  125. * Grids use a Row Selection Model by default, but this is easy to customise like so:
  126. *
  127. * Ext.create('Ext.grid.Panel', {
  128. * selType: 'cellmodel',
  129. * store: ...
  130. * });
  131. *
  132. * Specifying the `cellmodel` changes a couple of things. Firstly, clicking on a cell now
  133. * selects just that cell (using a {@link Ext.selection.RowModel rowmodel} will select the entire row), and secondly the
  134. * keyboard navigation will walk from cell to cell instead of row to row. Cell-based selection models are usually used in
  135. * conjunction with editing.
  136. *
  137. * ## Sorting &amp; Filtering
  138. *
  139. * Every grid is attached to a {@link Ext.data.Store Store}, which provides multi-sort and filtering capabilities. It's
  140. * easy to set up a grid to be sorted from the start:
  141. *
  142. * var myGrid = Ext.create('Ext.grid.Panel', {
  143. * store: {
  144. * fields: ['name', 'email', 'phone'],
  145. * sorters: ['name', 'phone']
  146. * },
  147. * columns: [
  148. * { text: 'Name', dataIndex: 'name' },
  149. * { text: 'Email', dataIndex: 'email' }
  150. * ]
  151. * });
  152. *
  153. * Sorting at run time is easily accomplished by simply clicking each column header. If you need to perform sorting on
  154. * more than one field at run time it's easy to do so by adding new sorters to the store:
  155. *
  156. * myGrid.store.sort([
  157. * { property: 'name', direction: 'ASC' },
  158. * { property: 'email', direction: 'DESC' }
  159. * ]);
  160. *
  161. * See {@link Ext.data.Store} for examples of filtering.
  162. *
  163. * ## State saving
  164. *
  165. * When configured {@link #stateful}, grids save their column state (order and width) encapsulated within the default
  166. * Panel state of changed width and height and collapsed/expanded state.
  167. *
  168. * Each {@link #columns column} of the grid may be configured with a {@link Ext.grid.column.Column#stateId stateId} which
  169. * identifies that column locally within the grid.
  170. *
  171. * ## Plugins and Features
  172. *
  173. * Grid supports addition of extra functionality through features and plugins:
  174. *
  175. * - {@link Ext.grid.plugin.CellEditing CellEditing} - editing grid contents one cell at a time.
  176. *
  177. * - {@link Ext.grid.plugin.RowEditing RowEditing} - editing grid contents an entire row at a time.
  178. *
  179. * - {@link Ext.grid.plugin.DragDrop DragDrop} - drag-drop reordering of grid rows.
  180. *
  181. * - {@link Ext.toolbar.Paging Paging toolbar} - paging through large sets of data.
  182. *
  183. * - {@link Ext.grid.PagingScroller Infinite scrolling} - another way to handle large sets of data.
  184. *
  185. * - {@link Ext.grid.RowNumberer RowNumberer} - automatically numbered rows.
  186. *
  187. * - {@link Ext.grid.feature.Grouping Grouping} - grouping together rows having the same value in a particular field.
  188. *
  189. * - {@link Ext.grid.feature.Summary Summary} - a summary row at the bottom of a grid.
  190. *
  191. * - {@link Ext.grid.feature.GroupingSummary GroupingSummary} - a summary row at the bottom of each group.
  192. */
  193. Ext.define('Ext.grid.Panel', {
  194. extend: 'Ext.panel.Table',
  195. requires: ['Ext.grid.View'],
  196. alias: ['widget.gridpanel', 'widget.grid'],
  197. alternateClassName: ['Ext.list.ListView', 'Ext.ListView', 'Ext.grid.GridPanel'],
  198. viewType: 'gridview',
  199. lockable: false,
  200. // Required for the Lockable Mixin. These are the configurations which will be copied to the
  201. // normal and locked sub tablepanels
  202. bothCfgCopy: [
  203. 'invalidateScrollerOnRefresh',
  204. 'hideHeaders',
  205. 'enableColumnHide',
  206. 'enableColumnMove',
  207. 'enableColumnResize',
  208. 'sortableColumns'
  209. ],
  210. normalCfgCopy: [
  211. 'verticalScroller',
  212. 'verticalScrollDock',
  213. 'verticalScrollerType',
  214. 'scroll'
  215. ],
  216. lockedCfgCopy: [],
  217. <span id='Ext-grid-Panel-cfg-rowLines'> /**
  218. </span> * @cfg {Boolean} rowLines False to remove row line styling
  219. */
  220. rowLines: true
  221. // Columns config is required in Grid
  222. <span id='Ext-grid-Panel-cfg-columns'> /**
  223. </span> * @cfg {Ext.grid.column.Column[]/Object} columns (required)
  224. * @inheritdoc
  225. */
  226. <span id='Ext-grid-Panel-event-reconfigure'> /**
  227. </span> * @event reconfigure
  228. * Fires after a reconfigure.
  229. * @param {Ext.grid.Panel} this
  230. * @param {Ext.data.Store} store The store that was passed to the {@link #method-reconfigure} method
  231. * @param {Object[]} columns The column configs that were passed to the {@link #method-reconfigure} method
  232. */
  233. <span id='Ext-grid-Panel-method-reconfigure'> /**
  234. </span> * @method reconfigure
  235. * Reconfigures the grid with a new store/columns. Either the store or the columns can be omitted if you don't wish
  236. * to change them.
  237. * @param {Ext.data.Store} store (Optional) The new store.
  238. * @param {Object[]} columns (Optional) An array of column configs
  239. */
  240. });</pre>
  241. </body>
  242. </html>