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
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";
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
You must alias any one ID with some other name.
The column names must be unique in grid.
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
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");
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