Beispiel #1
0
 /**
  * Generates grid component object
  *
  * @param \Engine\Crud\Grid\Extjs $grid
  * @return string
  */
 public static function _(Grid $grid)
 {
     $buildStore = $grid->isBuildStore();
     $code = "\n            buildStore: " . ($buildStore ? 'true' : 'false') . ",\n\n            initComponent: function() {\n                var me = this;\n\n                if (me.buildStore) {\n                    Ext.apply(me, {\n                        store : me.createStore(me.store)\n                    });\n                }\n\n                ";
     $editType = $grid->getEditingType();
     if ($editType) {
         $code .= "me.cellEditing = Ext.create('Ext.grid.plugin." . ucfirst($editType) . "Editing', {\n                    clicksToEdit: 2,\n                    listeners: {\n                        scope: me,\n                        edit: me.onEdit\n                    }\n                });\n                me.plugins = me.cellEditing;";
     }
     $code .= "\n                me.columns = me.columnsGet();\n                me.tbar    = me.getTopToolbarItems();\n                me.bbar    = me.getBottomToolbarItems();\n\n                me.callParent(arguments);\n            },\n\n            ";
     /*        me.on('selectionchange', me.onSelect, this);
                     me.on('celldblclick', me.onDbClick, this);
                     me.on('cellclick', me.onClick, this);
                     me.on('keypress', me.onKeyPress, this);
                 },";
             */
     return $code;
 }
Beispiel #2
0
 /**
  * Generates a widget to show a html grid
  *
  * @param \Engine\Crud\Grid\Extjs $grid
  * @return string
  */
 public static function _(Grid $grid)
 {
     $title = $grid->getTitle();
     $code = "\n        Ext.define('" . static::getGridName() . "', {\n            extend: 'Ext.ux.crud.Grid',\n            store: '" . static::getStoreName() . "',\n            alias: 'widget." . static::$_module . ucfirst(static::$_prefix) . "Grid',\n            ";
     $width = $grid->getWidth();
     if ($width) {
         $code .= "width: " . $width . ",\n            ";
     }
     $height = $grid->getHeight();
     if ($width) {
         $code .= "height: " . $height . ",\n            ";
     }
     $editType = $grid->getEditingType();
     if ($editType) {
         static::addRequires("Ext.grid.plugin." . ucfirst($editType) . "Editing");
     }
     static::addRequires("Ext.form.field.*");
     static::addRequires("Ext.ux.crud.Grid");
     $code .= "itemId: '" . static::$_module . ucfirst(static::$_prefix) . "Grid',";
     return $code;
 }