* Please note this feature is only available in paid versions.
- $obj_grid: phpGrid object as subgrid
- $s_fkey: subgrid foreign key.
- $m_fkey: Optional. Master foreign key.
- 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 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)
$dg->set_subgrid($sdg, 'sales_rep', 'id');
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.
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
// 2nd grid as detail grid
$sdg = new C_DataGrid("SELECT * FROM orderdetails", array("orderLineNumber", "productCode"), "orderdetails");
// 3rd grid as detail grid.
$sdg2 = new C_DataGrid("SELECT * FROM products", array("productCode"), "products");
// 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