Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / CheckColumn.html
diff --git a/docs/source/CheckColumn.html b/docs/source/CheckColumn.html
new file mode 100644 (file)
index 0000000..225156b
--- /dev/null
@@ -0,0 +1,83 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">Ext.ns('Ext.ux.grid');\r
+\r
+<div id="cls-Ext.ux.grid.CheckColumn"></div>/**\r
+ * @class Ext.ux.grid.CheckColumn\r
+ * @extends Object\r
+ * GridPanel plugin to add a column with check boxes to a grid.\r
+ * <p>Example usage:</p>\r
+ * <pre><code>\r
+// create the column\r
+var checkColumn = new Ext.grid.CheckColumn({\r
+   header: 'Indoor?',\r
+   dataIndex: 'indoor',\r
+   id: 'check',\r
+   width: 55\r
+});\r
+\r
+// add the column to the column model\r
+var cm = new Ext.grid.ColumnModel([{\r
+       header: 'Foo',\r
+       ...\r
+    },\r
+    checkColumn\r
+]);\r
+\r
+// create the grid\r
+var grid = new Ext.grid.EditorGridPanel({\r
+    ...\r
+    cm: cm,\r
+    plugins: [checkColumn], // include plugin\r
+    ...\r
+});\r
+ * </code></pre>\r
+ * In addition to storing a Boolean value within the record data, this\r
+ * class toggles a css class between <tt>'x-grid3-check-col'</tt> and\r
+ * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for\r
+ * a column.\r
+ */\r
+Ext.ux.grid.CheckColumn = function(config){\r
+    Ext.apply(this, config);\r
+    if(!this.id){\r
+        this.id = Ext.id();\r
+    }\r
+    this.renderer = this.renderer.createDelegate(this);\r
+};\r
+\r
+Ext.ux.grid.CheckColumn.prototype ={\r
+    init : function(grid){\r
+        this.grid = grid;\r
+        this.grid.on('render', function(){\r
+            var view = this.grid.getView();\r
+            view.mainBody.on('mousedown', this.onMouseDown, this);\r
+        }, this);\r
+    },\r
+\r
+    onMouseDown : function(e, t){\r
+        if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){\r
+            e.stopEvent();\r
+            var index = this.grid.getView().findRowIndex(t);\r
+            var record = this.grid.store.getAt(index);\r
+            record.set(this.dataIndex, !record.data[this.dataIndex]);\r
+        }\r
+    },\r
+\r
+    renderer : function(v, p, record){\r
+        p.css += ' x-grid3-check-col-td'; \r
+        return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'">&#160;</div>';\r
+    }\r
+};\r
+\r
+// register ptype\r
+Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);\r
+\r
+// backwards compat\r
+Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;</pre>    \r
+</body>\r
+</html>
\ No newline at end of file