Hide Primary Key in DB Table Grid

QuestionsHide Primary Key in DB Table Grid
Tony Wolsey asked 3 months ago

Hi Abu

 

Is there an easy way to hide the Primary Key field (“id”) in DB Table Grid php. “SELECT ALL” defaults to select all fields.

thanks

Tony

6 Answers
Abu Ghufran Staff answered 3 months ago

You can edit code and around line 81, set:

$grid[“hidefirst”] = true;
$g->set_options($grid);

hidefirst hides first column which is usually PK of table. It might work for your case.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Tony Wolsey answered 3 months ago

Thanks Abu but nothing changes. The primary key is still shown unfortunately.

 

thanks

Tony

 

Tony Wolsey answered 3 months ago

Thanks Abu but nothing changes. The primary key is still shown unfortunately.   thanks Tony

Py answered 2 months ago

You can use  hidden=true :

$col = array();
$col[“title”] = “Id”;
$col[“name”] = “id”;
$col[“hidden”] = true;
$cols[] = $col;

$g->set_columns($cols);

$out = $g->render(“list1”);

 

Abu Ghufran Staff answered 2 months ago

You can use this updated code:

https://gist.github.com/gridphp/60aa1b04dfa4758c14fff92d8f7e068f

It now contains global variable to control first column display.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Tony Wolsey answered 2 months ago

Thank you so much Abu! As always, it works brilliantly.

thank you

Tony

 

Your Answer

6 + 4 =

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 / 5. Vote count:

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

Let us improve this post!