I have downloaded PHP Grid from this URL. http://www.phpgrid.org/ (free) I can now connect to db and see the table list and all. Now, what I want to do is, I don't want the user to edit the primary key for each row in Add and Edit functionality. I have went through the forum and FAQ in their website, but still the code is not working Here is my code – The Primary ID SHOULD NOT BE EDITABLE anywhere (inline edit, add & edit functionality).
<?php
$conn = mysql_connect("localhost", "root", "password");
mysql_select_db("test");
mysql_query("SET NAMES 'utf8'");
include("inc/jqgrid_dist.php");
$g = new jqgrid();
$grid["caption"] = "Book(s)";
$grid["multiselect"] = false;
$grid["add_options"]["beforeInitData"] = "function(formid) { $('#list1').jqGrid('setColProp','b_id',{editable:false}); }";
$grid["add_options"]["afterShowForm"] = "function(formid) { $('#list1').jqGrid('setColProp','b_id',{editable:false}); }";
$g->set_options($grid);
$g->set_actions(array(
"add"=>true, // allow/disallow add
"edit"=>true, // allow/disallow edit
"delete"=>true, // allow/disallow delete
"rowactions"=>false, // show/hide row wise edit/del/save option
)
);
$g->table = "books";
$out = $g->render("list1");
?>
How to make the column b_id not editable. If possible, I will be happy if the inline edit is disabled for all the fields Thanks, Kimz
In here you will find your answer: http://www.phpgrid.org/docs/#column-options
You can use very easy like this
…
$g = new jqgrid();
$grid["caption"] = "Book(s)";
$grid["multiselect"] = false;
$col = array();
$col["name"] = "b_id";
$col["editable"] = false; //this will tell that this col is not editable
$cols[] = $col;
// ++ Other col
$g->set_columns($cols);
…
For inline edit (I started working yesterday with the grid 🙂 ) I think you can put in
$g->set_actions(array(
…
"rowactions"=>true
…
)
);