PHP Data Grid MYSQL Disable

QuestionsPHP Data Grid MYSQL Disable
Kimz asked 11 years ago

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

3 Answers
SirShadow answered 11 years ago

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);

SirShadow answered 11 years ago

For inline edit (I started working yesterday with the grid 🙂 ) I think you can put in

$g->set_actions(array(

"rowactions"=>true

)
);

Abu Ghufran answered 11 years ago

To disable PK editing, you have to define columns of grid (using set_columns function), and set the primary key column as
$col["hidden"] = false;

Your Answer

20 + 20 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?