Can't seem to hide colummn

QuestionsCan't seem to hide colummn
Calvin Tomkins asked 9 years ago

Hello

I'm using the following query to show data in my table:

$g->select_command = "SELECT Certificates.ID, Products.`PName`, Certificates.Type, Certificates.Date, Certificates.SupplierID FROM Certificates
INNER JOIN Products ON Certificates.ProductID = Products.ID
WHERE Certificates.SupplierID =$supplier_id";

And I want to hide the ID column so I put:

$col = array();
$col["name"] = "Certificates.ID";
$col["hidden"] = true;
$cols[] = $col;

But it still shows. What am I doing wrong?

Thanks in advance for any help.

Calvin

7 Answers
Abu Ghufran answered 9 years ago

Hi,

$col["name"] = "Certificates.ID";
should be:
$col["name"] = "ID";

For search case, and to solve ambiguous issue you can set:

$col["dbname"] = "Certificates.ID";

Calvin Tomkins answered 9 years ago

Hi Abu

I do have an ambiguous issue as both the tables have a column called ID. But

$col = array();
$col["dbname"] = "Certificates.ID";
$col["hidden"] = true;
$cols[] = $col;

or

$col = array();
$col["name"] = "ID";
$col["dbname"] = "Certificates.ID";
$col["hidden"] = true;
$cols[] = $col;

dont seem to hide it.

Any ideas?

Thanks

Abu Ghufran answered 9 years ago

You must alias any one ID with some other name.
The column names must be unique in grid.

Calvin Tomkins answered 9 years ago

Hi Abu

Thanks for your quick replies!

I've added an alias to the column, but don't seem to work still…

Please see here http://bakerite.co.uk/scl/test.txt

Thanks

Abu Ghufran answered 9 years ago

Must use set_columns … change with:

// set database table for CRUD operations
$g->select_command = "SELECT Certificates.ID AS `Cid`, Products.`PName`, Certificates.Type, Certificates.Date, Certificates.SupplierID AS `Sid` FROM Certificates
INNER JOIN Products ON Certificates.ProductID = Products.ID
WHERE Certificates.SupplierID =$supplier_id";

$col = array();
$col["name"] = "Cid";
$col["hidden"] = true;
$cols[] = $col;

$g->set_columns($cols,true);

// render grid
$out = $g->render("list1");

Calvin Tomkins answered 9 years ago

Hi Abu

That hides all columns!

Thanks

Abu Ghufran answered 9 years ago

Don't know exactly the issue, but to make it clear, define all columns like mentioned in docs.
http://www.phpgrid.org/docs/#Selecting_Specific_Columns

Your Answer

10 + 16 =

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?