Hide Primary Key in DB Table Grid

QuestionsHide Primary Key in DB Table Grid
Tony Wolsey asked 1 year 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 1 year 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
Grid 4 PHP Framework
 
Tony Wolsey answered 1 year ago

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

 

thanks

Tony

 

Tony Wolsey answered 1 year ago

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

Py answered 1 year 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 1 year 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
Grid 4 PHP Framework
 
Tony Wolsey answered 1 year ago

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

thank you

Tony

 

Your Answer

18 + 18 =

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?