read only Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Tue, 03 Dec 2024 18:28:20 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Read only fields https://phpgrid.com/example/read-only-fields/ Thu, 16 Sep 2010 23:59:45 +0000 http://64.38.236.7/?p=540 Sometimes we don’t want certain fields to be editable, then we can use set_col_readonly() method. Note that you can set more than one columns to be read only using this method. 123456789101112131415161718192021use phpCtrl\C_DataGrid; require_once("/file/path/to/conf.php");   $dg = new C_DataGrid("SELECT * FROM Orders", "orderNumber", "Orders"); // change column titles $dg -> set_col_title("orderNumber", "Order No."); $dg -> […]

The post Read only fields appeared first on phpGrid - PHP Datagrid.

]]>
Sometimes we don’t want certain fields to be editable, then we can use set_col_readonly() method.

Note that you can set more than one columns to be read only using this method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

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

// change column titles
$dg -> set_col_title("orderNumber", "Order No.");
$dg -> set_col_title("orderDate", "Order Date");
$dg -> set_col_title("shippedDate", "Shipped Date");
$dg -> set_col_title("customerNumber", "Customer No.");

// enable edit
$dg ->enable_edit("INLINE", "CRUD");
 
// hide a column
$dg -> set_col_hidden("requiredDate");

// read only columns, one or more columns delimited by comma
$dg -> set_col_readonly("orderDate, customerNumber");
 
$dg -> display();

To allow add for read-only field when adding new records, use “jqGridAddEditAfterShowForm” event, and conditionally remove the “disabled” attribute based on operand, which is either “edit” or “add”.

1
2
3
4
5
6
$dg -> add_event('jqGridAddEditAfterShowForm',
  'function(e, form, oper){
    if (oper == "add") {
      $("#COLUMN_NAME").removeAttr("disabled");
    }
  }'
);

Click on row to see the fields that are set to read-only.

See Live Example!

The post Read only fields appeared first on phpGrid - PHP Datagrid.

]]>
540