Hide Primary Key in DB Table Grid

QuestionsHide Primary Key in DB Table Grid
Tony Wolsey asked 6 years 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 6 years 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 6 years ago

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

 

thanks

Tony

 

Tony Wolsey answered 5 years ago

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

Py answered 5 years 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 5 years 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 5 years ago

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

thank you

Tony

 

Your Answer

20 + 0 =

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?