I have a grid populated by a database. One of the columns is a concat of 2 columns in another table. In this case it is a team's location and name. However, when I click on edit and the edit form gets populated, it always picks the first team in the dropdown as opposed to the actual team in the database.
Here is some of the relevant code:
jQuery("#listPlayer").jqGrid({
url:'../controller/playerGrid.php',
datatype: "json",
colNames:['ID','First Name','Last Name', 'Team'],
colModel:[
{name:'id', index:'id', width:20, editable:false, hidden:true},
{name:'first_name', index:'first_name', width:80, editable:true, editrules: {required: true}},
{name:'last_name', index:'last_name', width:80, editable:true, editrules: {required: true}},
{name:'idTeam', index:'idTeam', width:50, editable:true, editrules: {required: true}, edittype: 'select', editoptions: { dataUrl: "../controller/listTable.php?query=team" } }
],
rowNum:50,
rowTotal: 2000,
rowList : [20,30,50],
mtype: "POST",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#pagerPlayer',
sortname: 'last_name',
viewrecords: true,
sortorder: "asc",
caption: "Player Manager",
editurl: "../controller/playerEditGrid.php"
And this is what the SQL query in listTable.php looks like:
SELECT t.id, CONCAT(t.location, ' ', t.name,' (', l.abbr, ')' ) as idTeam FROM team t, league l WHERE t.idLeague = l.id ORDER BY t.location
I know the problem lies in the fact that it's a concatenation as opposed to a single column but I'm sure there's a way around it... I just don't know it.