PhpExt : Grid [ class tree ] [ index ] [ all elements ]

Source for file GridPanel.php

Documentation is available at GridPanel.php

  1. <?php
  2. /**
  3.  * PHP-Ext Library
  4.  * http://php-ext.googlecode.com
  5.  * @author Sergei Walter <sergeiw[at]gmail[dot]com>
  6.  * @copyright 2008 Sergei Walter
  7.  * @license http://www.gnu.org/licenses/lgpl.html
  8.  * @link http://php-ext.googlecode.com
  9.  * 
  10.  *  Reference for Ext JS: http://extjs.com
  11.  * 
  12.  */
  13.  
  14. /**
  15.  * @see PhpExt_Panel
  16.  */
  17. include_once 'PhpExt/Panel.php';
  18. /**
  19.  * @see PhpExt_Grid_ColumnModel
  20.  */
  21. include_once 'PhpExt/Grid/ColumnModel.php';
  22. /**
  23.  * @see PhpExt_Grid_AbstractSelectionModell
  24.  */
  25. include_once 'PhpExt/Grid/AbstractSelectionModel.php';
  26. /**
  27.  * @see PhpExt_Data_Store
  28.  */
  29. include_once 'PhpExt/Data/Store.php';
  30. /**
  31.  * @see PhpExt_Grid_GridView
  32.  */
  33. include_once 'PhpExt/Grid/GridView.php';
  34.  
  35.  
  36. /**
  37.  * This class represents the primary interface of a component based grid control.
  38.  * 
  39.  * Usage:
  40.  * <code>
  41.  *    var grid = new Ext.grid.GridPanel({
  42.  *        store: new Ext.data.Store({
  43.  *            reader: reader,
  44.  *            data: xg.dummyData
  45.  *        }),
  46.  *        columns: [
  47.  *            {id:'company', header: "Company", width: 200, sortable: true, dataIndex: 'company'},
  48.  *            {header: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  49.  *            {header: "Change", width: 120, sortable: true, dataIndex: 'change'},
  50.  *            {header: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'},
  51.  *            {header: "Last Updated", width: 135, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  52.  *        ],
  53.  *        viewConfig: {
  54.  *            forceFit: true
  55.  *        },
  56.  *        sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
  57.  *        width:600,
  58.  *        height:300,
  59.  *        frame:true,
  60.  *        title:'Framed with Checkbox Selection and Horizontal Scrolling',
  61.  *        iconCls:'icon-grid'
  62.  *    });
  63.  *    </code>
  64.  *    Note: Although this class inherits many configuration options from base classes, some of them (such as autoScroll, layout, items, etc) won't function as they do with the base Panel class.
  65.  *    
  66.  *    To access the data in a Grid, it is necessary to use the data model encapsulated by the Store.
  67.  *
  68.  * @package PhpExt
  69.  * @subpackage Grid
  70.  */
  71. {
  72.     // AutoExpandColumn
  73.     /**
  74.      * The id of a column in this grid that should expand to fill unused space. This id can not be 0.
  75.      * @param string $value 
  76.      * @return PhpExt_Grid_GridPanel 
  77.      */
  78.     public function setAutoExpandColumn($value{
  79.         $this->setExtConfigProperty("autoExpandColumn"$value);
  80.         return $this;
  81.     }    
  82.     /**
  83.      * The id of a column in this grid that should expand to fill unused space. This id can not be 0.
  84.      * @return string 
  85.      */
  86.     public function getAutoExpandColumn({
  87.         return $this->getExtConfigProperty("autoExpandColumn");
  88.     }
  89.     
  90.     // AutoExpandMax
  91.     /**
  92.      * The maximum width the autoExpandColumn can have (if enabled). Defaults to 1000.
  93.      * @param integer $value 
  94.      * @return PhpExt_Grid_GridPanel 
  95.      */
  96.     public function setAutoExpandMax($value{
  97.         $this->setExtConfigProperty("autoExpandMax"$value);
  98.         return $this;
  99.     }    
  100.     /**
  101.      * The maximum width the autoExpandColumn can have (if enabled). Defaults to 1000.
  102.      * @return integer 
  103.      */
  104.     public function getAutoExpandMax({
  105.         return $this->getExtConfigProperty("autoExpandMax");
  106.     }
  107.     
  108.     // AutoExpandMin
  109.     /**
  110.      * The minimum width the autoExpandColumn can have (if enabled). defaults to 50.
  111.      * @param integer $value 
  112.      * @return PhpExt_Grid_GridPanel 
  113.      */
  114.     public function setAutoExpandMin($value{
  115.         $this->setExtConfigProperty("autoExpandMin"$value);
  116.         return $this;
  117.     }    
  118.     /**
  119.      * The minimum width the autoExpandColumn can have (if enabled). defaults to 50.
  120.      * @return integer 
  121.      */
  122.     public function getAutoExpandMin({
  123.         return $this->getExtConfigProperty("autoExpandMin");
  124.     }
  125.     
  126.     // ColumnModel
  127.     /**
  128.      * @var PhpExt_Grid_ColumnModel 
  129.      */
  130.     public $_columnModel = null;
  131.     /**
  132.      * The {@link PhpExt_Grid_ColumnModel} to use when rendering the grid (required).
  133.      * @param PhpExt_Grid_ColumnModel $value 
  134.      * @return PhpExt_Grid_GridPanel 
  135.      */
  136.     public function setColumnModel(PhpExt_Grid_ColumnModel $value{
  137.         $this->_columnModel = $value;
  138.         $this->setExtConfigProperty("colModel"$value);
  139.         return $this;
  140.     }    
  141.     /**
  142.      * The {@link PhpExt_Grid_ColumnModel} to use when rendering the grid (required).
  143.      * @return PhpExt_Grid_ColumnModel 
  144.      */
  145.     public function getColumnModel({
  146.         return $this->getExtConfigProperty("colModel");
  147.     }
  148.     
  149.     // DisableSelection
  150.     /**
  151.      * True to disable selections in the grid (defaults to false). - ignored a SelectionModel is specified
  152.      * @param boolean $value 
  153.      * @return PhpExt_Grid_GridPanel 
  154.      */
  155.     public function setDisableSelection($value{
  156.         $this->setExtConfigProperty("disableSelection"$value);
  157.         return $this;
  158.     }    
  159.     /**
  160.      * True to disable selections in the grid (defaults to false). - ignored a SelectionModel is specified
  161.      * @return boolean 
  162.      */
  163.     public function getDisableSelection({
  164.         return $this->getExtConfigProperty("disableSelection");
  165.     }
  166.     
  167.     // EnableColumnHide
  168.     /**
  169.      * True to enable hiding of columns with the header context menu.
  170.      * @param boolean $value 
  171.      * @return PhpExt_Grid_GridPanel 
  172.      */
  173.     public function setEnableColumnHide($value{
  174.         $this->setExtConfigProperty("enableColumnHide"$value);
  175.         return $this;
  176.     }    
  177.     /**
  178.      * True to enable hiding of columns with the header context menu.
  179.      * @return boolean 
  180.      */
  181.     public function getEnableColumnHide({
  182.         return $this->getExtConfigProperty("enableColumnHide");
  183.     }
  184.     
  185.     // EnableColumnMove
  186.     /**
  187.      * True to enable drag and drop reorder of columns.
  188.      * @param boolean $value 
  189.      * @return PhpExt_Grid_GridPanel 
  190.      */
  191.     public function setEnableColumnMove($value{
  192.         $this->setExtConfigProperty("enableColumnMove"$value);
  193.         return $this;
  194.     }    
  195.     /**
  196.      * True to enable drag and drop reorder of columns.
  197.      * @return boolean 
  198.      */
  199.     public function getEnableColumnMove({
  200.         return $this->getExtConfigProperty("enableColumnMove");
  201.     }
  202.     
  203.     // EnableColumnResize
  204.     /**
  205.      * False to turn off column resizing for the whole grid (defaults to true).
  206.      * @param boolean $value 
  207.      * @return PhpExt_Grid_GridPanel 
  208.      */
  209.     public function setEnableColumnResize($value{
  210.         $this->setExtConfigProperty("enableColumnResize"$value);
  211.         return $this;
  212.     }    
  213.     /**
  214.      * False to turn off column resizing for the whole grid (defaults to true).
  215.      * @return boolean 
  216.      */
  217.     public function getEnableColumnResize({
  218.         return $this->getExtConfigProperty("enableColumnResize");
  219.     }
  220.     
  221.     // EnableDragDrop
  222.     /**
  223.      * True to enable drag and drop of rows.
  224.      * @param boolean $value 
  225.      * @return PhpExt_Grid_GridPanel 
  226.      */
  227.     public function setEnableDragDrop($value{
  228.         $this->setExtConfigProperty("enableDragDrop"$value);
  229.         return $this;
  230.     }    
  231.     /**
  232.      * True to enable drag and drop of rows.
  233.      * @return boolean 
  234.      */
  235.     public function getEnableDragDrop({
  236.         return $this->getExtConfigProperty("enableDragDrop");
  237.     }
  238.     
  239.     // EnableHeaderMenu
  240.     /**
  241.      * True to enable the drop down button for menu in the headers.
  242.      * @param boolean $value 
  243.      * @return PhpExt_Grid_GridPanel 
  244.      */
  245.     public function setEnableHeaderMenu($value{
  246.         $this->setExtConfigProperty("enableHdMenu"$value);
  247.         return $this;
  248.     }    
  249.     /**
  250.      * True to enable the drop down button for menu in the headers.
  251.      * @return boolean 
  252.      */
  253.     public function getEnableHeaderMenu({
  254.         return $this->getExtConfigProperty("enableHdMenu");
  255.     }
  256.     
  257.     // EnableRowHeightSync
  258.     /**
  259.      * True to manually sync row heights across locked and not locked rows.
  260.      * @param boolean $value 
  261.      * @return PhpExt_Grid_GridPanel 
  262.      */
  263.     public function setEnableRowHeightSync($value{
  264.         $this->setExtConfigProperty("enableRowHeightSync"$value);
  265.         return $this;
  266.     }    
  267.     /**
  268.      * True to manually sync row heights across locked and not locked rows.
  269.      * @return boolean 
  270.      */
  271.     public function getEnableRowHeightSync({
  272.         return $this->getExtConfigProperty("enableRowHeightSync");
  273.     }
  274.     
  275.     // LoadMask
  276.     /**
  277.      * An {@link PhpExt_LoadMask} object or true to mask the grid while loading (defaults to false).
  278.      * @param PhpExt_LoadMask|boolean$value 
  279.      * @return PhpExt_Grid_GridPanel 
  280.      */
  281.     public function setLoadMask($value{
  282.         $this->setExtConfigProperty("loadMask"$value);
  283.         return $this;
  284.     }    
  285.     /**
  286.      * An {@link PhpExt_LoadMask} object or true to mask the grid while loading (defaults to false).
  287.      * @return PhpExt_LoadMask|boolean
  288.      */
  289.     public function getLoadMask({
  290.         return $this->getExtConfigProperty("loadMask");
  291.     }
  292.     
  293.     // MaxHeight
  294.     /**
  295.      * Sets the maximum height of the grid - ignored if autoHeight is not on.
  296.      * @param integer $value 
  297.      * @return PhpExt_Grid_GridPanel 
  298.      */
  299.     public function setMaxHeight($value{
  300.         $this->setExtConfigProperty("maxHeight"$value);
  301.         return $this;
  302.     }    
  303.     /**
  304.      * Sets the maximum height of the grid - ignored if autoHeight is not on.
  305.      * @return integer 
  306.      */
  307.     public function getMaxHeight({
  308.         return $this->getExtConfigProperty("maxHeight");
  309.     }
  310.     
  311.     // MinColumnWidth
  312.     /**
  313.      * The minimum width a column can be resized to. Defaults to 25.
  314.      * @param integer $value 
  315.      * @return PhpExt_Grid_GridPanel 
  316.      */
  317.     public function setMinColumnWidth($value{
  318.         $this->setExtConfigProperty("minColumnWidth"$value);
  319.         return $this;
  320.     }    
  321.     /**
  322.      * The minimum width a column can be resized to. Defaults to 25.
  323.      * @return integer 
  324.      */
  325.     public function getMinColumnWidth({
  326.         return $this->getExtConfigProperty("minColumnWidth");
  327.     }
  328.     
  329.     // MonitorWindowResize
  330.     /**
  331.      * True to autoSize the grid when the window resizes. Defaults to true.
  332.      * @param boolean $value 
  333.      * @return PhpExt_Grid_GridPanel 
  334.      */
  335.     public function setMonitorWindowResize($value{
  336.         $this->setExtConfigProperty("monitorWindowResize"$value);
  337.         return $this;
  338.     }    
  339.     /**
  340.      * True to autoSize the grid when the window resizes. Defaults to true.
  341.      * @return boolean 
  342.      */
  343.     public function getMonitorWindowResize({
  344.         return $this->getExtConfigProperty("monitorWindowResize");
  345.     }
  346.     
  347.     // SelectionModel
  348.     /**
  349.      * Any subclass of {@link PhpExt_Grid_AbstractSelectionModel} that will provide the selection model for the grid (defaults to {@link PhpExt_Grid_RowSelectionModel} if not specified).
  350.      * 
  351.      * @param PhpExt_Grid_AbstractSelectionModel $value 
  352.      * @return PhpExt_Grid_GridPanel 
  353.      */
  354.     public function setSelectionModel(PhpExt_Grid_AbstractSelectionModel $value{
  355.         $this->setExtConfigProperty("selModel"$value);
  356.         return $this;
  357.     }    
  358.     /**
  359.      * Any subclass of {@link PhpExt_Grid_AbstractSelectionModel} that will provide the selection model for the grid (defaults to {@link PhpExt_Grid_RowSelectionModel} if not specified).
  360.      * 
  361.      * @return PhpExt_Grid_AbstractSelectionModel 
  362.      */
  363.     public function getSelectionModel({
  364.         return $this->getExtConfigProperty("selModel");
  365.     }
  366.     
  367.     // Store
  368.     /**
  369.      * The {@link PhpExt_Data_Store} the grid should use as its data source (required).
  370.      * @param PhpExt_Data_Store $value 
  371.      * @return PhpExt_Grid_GridPanel 
  372.      */
  373.     public function setStore(PhpExt_Data_Store $value{
  374.         $this->setExtConfigProperty("store"$value);
  375.         return $this;
  376.     }    
  377.     /**
  378.      * The {@link PhpExt_Data_Store} the grid should use as its data source (required).
  379.      * @return PhpExt_Data_Store 
  380.      */
  381.     public function getStore({
  382.         return $this->getExtConfigProperty("store");
  383.     }
  384.     
  385.     // StripeRows
  386.     /**
  387.      * True to stripe the rows. Default is false.
  388.      * @param boolean $value 
  389.      * @return PhpExt_Grid_GridPanel 
  390.      */
  391.     public function setStripeRows($value{
  392.         $this->setExtConfigProperty("stripeRows"$value);
  393.         return $this;
  394.     }    
  395.     /**
  396.      * True to stripe the rows. Default is false.
  397.      * @return boolean 
  398.      */
  399.     public function getStripeRows({
  400.         return $this->getExtConfigProperty("stripeRows");
  401.     }
  402.     
  403.     // TrackMouseOver
  404.     /**
  405.      * True to highlight rows when the mouse is over. Default is true.
  406.      * @param boolean $value 
  407.      * @return PhpExt_Grid_GridPanel 
  408.      */
  409.     public function setTrackMouseOver($value{
  410.         $this->setExtConfigProperty("trackMouseOver"$value);
  411.         return $this;
  412.     }    
  413.     /**
  414.      * True to highlight rows when the mouse is over. Default is true.
  415.      * @return boolean 
  416.      */
  417.     public function getTrackMouseOver({
  418.         return $this->getExtConfigProperty("trackMouseOver");
  419.     }
  420.     
  421.     // View
  422.     /**
  423.      * The {@link PhpExt_Grid_GridView} used by the grid. This can be set before a call to render().
  424.      * @see PhpExt_Grid_GridView
  425.      * @see PhpExt_Grid_GroupingView
  426.      * @param PhpExt_Grid_GridView $value 
  427.      * @return PhpExt_Grid_GridPanel 
  428.      */
  429.     public function setView($value{
  430.         $this->setExtConfigProperty("view"$value);
  431.         return $this;
  432.     }    
  433.     /**
  434.      * The {@link PhpExt_Grid_GridView} used by the grid. This can be set before a call to render().
  435.      * @see PhpExt_Grid_GridView
  436.      * @see PhpExt_Grid_GroupingView
  437.      * @return PhpExt_Grid_GridView 
  438.      */
  439.     public function getView({
  440.         return $this->getExtConfigProperty("view");
  441.     }    
  442.     
  443.     public function __construct({
  444.         parent::__construct();
  445.         $this->setExtClassInfo("Ext.grid.GridPanel""grid");
  446.         
  447.         $validProps array(
  448.             "autoExpandColumn",
  449.             "autoExpandMax",
  450.             "autoExpandMin",
  451.             "colModel",
  452.             "disableSelection",
  453.             "enableColumnHide",
  454.             "enableColumnMove",
  455.             "enableColumnResize",
  456.             "enableDragDrop",
  457.             "enableHdMenu",
  458.             "enableRowHeightSync",
  459.             "loadMask",
  460.             "maxHeight",
  461.             "minColumnWidth",
  462.             "monitorWindowResize",
  463.             "selModel",
  464.             "store",
  465.             "stripeRows",
  466.             "trackMouseOver",
  467.             "view"
  468.         );
  469.         $this->addValidConfigProperties($validProps);
  470.     
  471.     }        
  472.      
  473.     
  474. }

Documentation generated on Fri, 08 Aug 2008 15:54:36 -0500 by phpDocumentor 1.4.0