4..5.5 Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Tue, 18 Jul 2023 17:59:28 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 set_col_default() https://phpgrid.com/documentation/set_col_default/ Sun, 08 Apr 2012 04:03:12 +0000 http://phpgrid.com/?p=2041 Parameters: $col_name: column name $default: column default value Description: Set column default value This option is only valid for Form Editing when adding a new record. Users can override this entry. Remark: To set the default value for edit existing records, use beforeEditRow event.  Be sure to set default only when the value is blank otherwise any populated […]

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

]]>
  • Parameters:
    • $col_name: column name
    • $default: column default value
  • Description:
    • Set column default value This option is only valid for Form Editing when adding a new record. Users can override this entry.
  • Remark:
    • To set the default value for edit existing records, use beforeEditRow event.  Be sure to set default only when the value is blank otherwise any populated values entered by users would be overwritten.
  • Example:
  • 1
    2
    $dg -> set_col_default('direction', 'top');
    $dg -> set_col_default('dateField',  date("Y-m-d H:m"));

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

    ]]>
    2041
    set_masterdetail() * https://phpgrid.com/documentation/set_masterdetail/ Wed, 15 Sep 2010 19:17:44 +0000 http://64.38.236.7/?p=454 * Please note this feature is only available in Premium and higher licenses.   Parameter(s): $obj_grid: phpGrid object as the detail datagrid $fkey: Foreign key of the detail grid to the master datagrid. $m_fkey: Foreign key of the master grid to the detail grid. It’s optional when $fkey and $m_fkey have the same column name. […]

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

    ]]>
    * Please note this feature is only available in Premium and higher licenses.

     

    • Parameter(s):
      • $obj_grid: phpGrid object as the detail datagrid
      • $fkey: Foreign key of the detail grid to the master datagrid.
      • $m_fkey: Foreign key of the master grid to the detail grid. It’s optional when $fkey and $m_fkey have the same column name. (supported since version 7.1)
    • Description:
      • This method sets the master detail, or the parent child, relationship between datagrids.
      • The phpGrid went the extra mile to make creating the master detail datagrid a simple task for developers. The primary key value of master datagrid is automatically retrieved when a user selects a row. The value is used as the foreign key for the detail datagrid. The detail datagrid renders dynamically based on the row selected in the master grid.
    • Remark (important):
      • The detail grid is a regular phpGrid object and can have the same methods like any other phpGrid, such as description title, sort, and update etc. A master detail can have one or more detail datagrid.
      • The foreign key, or $fkey, does NOT necessarily have to have the same name as the master table primary key, as long as the same name exists in both master and detail tables.
      • When foreign keys don’t have the same name, you should use SQL alias in the master grid. However, if the grid is editable, it’s important to call set_col_readonly() and seike>e new alias to be read only. the 3rd parameter to reference to the foreign key from the master datagrid.
      • By leaving the foreign key field blank in detail grid, master grid will prefill its detail grid with the value of the foreign key before the new record is saved/inserted to the database table. Or simply hide the entire foreign key column (Version 4.5.5 and above only).
    • Example:

    When the master detail reference keys have the same name,  the 3rd parameter can be omitted.

    1
    2
    3
    4
    // orderId exists in both master table(Orders) and detail table(OrderDetails)
    $dg = new C_DataGrid("SELECT orderId, orderDate, customerId FROM Orders", "orderNumber", "Orders");
    $sdg = new C_DataGrid("SELECT lineId, orderId, productCode, price FROM OrderDetails", "lineId", "OrderDetails");
    $dg -> set_masterdetail($sdg, 'orderId');

     

    Use the 3rd parameter when the keys to reference have different name in master and detail tables.

    1
    2
    3
    4
    5
    // productId is SQL alias to productNo in master table(ProductParts), then used as foreign key to link to detail table(Products).
    $dg = new C_DataGrid("SELECT partNo, partName, productNo FROM ProductParts", "partNo", "ProductParts");
    $dg -> enable_edit('INLINE', 'CRUD')->set_col_readonly("productId");
    $sdg = new C_DataGrid("SELECT productId, productName, productDescription FROM Products", "productId", "Products");
    $dg -> set_masterdetail($sdg, 'productId', 'productNo');

    Still having trouble editing master detail grids with column name alias?
    Please see Master detail grid with column name alias

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

    ]]>
    454