Skip to content

Dropdown Concatenation

Sometime you want to display multiple fields in a dropdown during editing such as last name and first name . 

A common workaround is to create SQL view:

// make sure give an alias to concatenated fields.
CREATE VIEW v_names AS 
SELECT ContactID,CONCAT(FirstName,' ', LastName) AS Name FROM contacts

Then in phpGrid, you can do 

$dg -> set_col_edittype("ContactID", "select", "SELECT ContactID, Name FROM v_names");

Without using sql view

$dg -> set_col_edittype("reportsTo", "select", "Select employeeNumber, concat(firstName, ' ', lastName) from employees", true);


Feedback and Knowledge Base