subgrid Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Tue, 03 Dec 2024 22:54:30 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Subgrid * https://phpgrid.com/example/subgrid/ Fri, 17 Sep 2010 04:43:35 +0000 http://64.38.236.7/?p=561     Defining a subgrid is essentially the same as setting up the master detail grid as described in our previous example. Again, only a single line of code change is required by calling set_subgrid(). phpGrid also supports single level with multiple subgrids, similar to master grid that has many detail grids. 12345678910111213141516171819202122// Always include […]

The post Subgrid * appeared first on phpGrid - PHP Datagrid.

]]>
subgrid multilevel

 
 

Defining a subgrid is essentially the same as setting up the master detail grid as described in our previous example. Again, only a single line of code change is required by calling set_subgrid(). phpGrid also supports single level with multiple subgrids, similar to master grid that has many detail grids.

Starting version 6, nested, drill-down subgrids are supported!
X
Due to the calling sequence, the enable_edit() should be called BEFORE set_subgrid() method, or edit properties will be ignored.
X
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");

// enable edit
$dg->enable_edit("INLINE", "CRUD");

// second grid as detail grid. Notice it is just another regular phpGrid with properties.
$sdg = new C_DataGrid("SELECT * FROM orderdetails", array("orderLineNumber", "productCode"), "orderdetails");
$sdg->enable_edit("INLINE", "CRUD");

// second grid as detail grid. Notice it is just another regular phpGrid with properties.
$sdg2 = new C_DataGrid("SELECT * FROM products", array("productCode"), "products");
$sdg2->enable_edit("INLINE", "CRUD");

// define master detail relationship by passing the detail grid object as the first parameter, then the foreign key name.
$sdg->set_subgrid($sdg2, 'productCode');
$dg->set_subgrid($sdg, 'orderNumber');

$dg->display();

See 3-Level Nested Subgrid Example!

The post Subgrid * appeared first on phpGrid - PHP Datagrid.

]]>
561
set_subgrid() https://phpgrid.com/documentation/set_subgrid/ Wed, 15 Sep 2010 19:27:08 +0000 http://64.38.236.7/?p=469 Parameter(s): $obj_grid: phpGrid object as subgrid $s_fkey: subgrid foreign key. $m_fkey: Optional. Master foreign key. Description: The method displays inline detail grid rather than in separate datagrid table. It is very similar to set_masterdetail(). When ignored, phpGrid assumes that m_fkey has the same value as the s_fkey.   The $m_fkey value from the master datagrid is automatically […]

The post set_subgrid() appeared first on phpGrid - PHP Datagrid.

]]>
  • Parameter(s):
    • $obj_grid: phpGrid object as subgrid
    • $s_fkey: subgrid foreign key.
    • $m_fkey: Optional. Master foreign key.
  • Description:
    • The method displays inline detail grid rather than in separate datagrid table. It is very similar to set_masterdetail(). When ignored, phpGrid assumes that m_fkey has the same value as the s_fkey.
    •  new The $m_fkey value from the master datagrid is automatically retrieved when a user selects a row.  The value is passed to the pop-up Add form in the subgrid.  ( supported since 7.1.5)
      1
      2
      3
      ...
      $dg->set_subgrid($sdg, 'sales_rep', 'id');
      ...

      subgrid-master-linking-value

  • Remark:
    • Edit is currently not supported in subgrid.
    • Nested subgrid is currently not supported,  Nested/drill-down subgrid is now supported (version 6+).
    • The order of the 2nd and 3rd parameter matters,
    • When the subgrid is the same table(self-reference, in database term) as the master grid, subgrid must use a different table alias in select statement using set_jq_gridName().
    • All the grid properties and method should be called BEFORE set_subgrid is called.
    • Do not include ‘WHERE’ in set_query_filter() when used on subgrid.
    • Due to the calling sequence, the enable_edit() should be called BEFORE set_subgrid() method, or edit properties will be ignored.
  • Example:
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
    $dg->enable_edit("INLINE", "CRUD");

    // 2nd grid as detail grid
    $sdg = new C_DataGrid("SELECT * FROM orderdetails", array("orderLineNumber", "productCode"), "orderdetails");
    $sdg->enable_edit("INLINE", "CRUD");

    // 3rd grid as detail grid.
    $sdg2 = new C_DataGrid("SELECT * FROM products", array("productCode"), "products");
    $sdg2->enable_edit("INLINE", "CRUD");

    // passing the detail grid object as the first parameter, then the foreign key name.
    // set_subgrid should be the last method to call before display
    $sdg->set_subgrid($sdg2, 'productCode');
    $dg->set_subgrid($sdg, 'orderNumber');

    $dg->display();

    The post set_subgrid() appeared first on phpGrid - PHP Datagrid.

    ]]>
    469