Hi ,
from your example, I’d like to set setcolproperty with multi condition :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
grid.php. <!--?php require_once '../../jq-config.php'; // include the jqGrid Class require_once ABSPATH."php/PHPSuito/jqGrid.php"; // include the driver class require_once ABSPATH."php/PHPSuito/DBdrivers/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8");<br ?--> $noEdit = $_REQUEST[log]; // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT CustomerID, CompanyName, Phone, PostalCode, City FROM customers'; // Set the table to where you add the data $grid->table = 'customers'; $grid->setPrimaryKeyId('CustomerID'); $grid->serialKey = false; // Set output format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set some grid options $grid->setGridOptions(array( "rowNum"=>10, "rowList"=>array(10,20,30), "sortname"=>"CustomerID" )); // The primary key should be entered $grid->setColProperty('CustomerID', array("editrules"=>array("required"=>true))); if ($noEdit) { $grid->setColProperty("CompanyName",array("editable"=>false)); $grid->setColProperty("Phone",array("editable"=>false)); } else { $grid->setColProperty("CompanyName",array("editable"=>true)); $grid->setColProperty("Phone",array("editable"=>true)); } // Enable navigator $grid->navigator = true; // Enable only deleting $grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>false, "search"=>false)); // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); |
focusing on this code :
|
1 2 3 4 5 6 7 8 9 10 11 |
if ($noEdit) { $grid->setColProperty("CompanyName",array("editable"=>false)); $grid->setColProperty("Phone",array("editable"=>false)); } else { $grid->setColProperty("CompanyName",array("editable"=>true)); $grid->setColProperty("Phone",array("editable"=>true)); } |
But nothing happen. Grid always show setting from the first time fired.
Thank you.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top