Forum


17:35

28/12/2009

I am trying to follow the demo @ http://trirand.com/blog/jqgrid.....qgrid.html Advanced > Master Detail which is basically has a Main grid and when you click on a row on the Master Grid a subgrid is populated with data about that id.
The data I have in my primary grid is somewhat of a log of computers, and these computers repeat themselves numerous times. I have other tables in my db that share other specific computer information that I'd like to display on the subgrid but the problem I am having is that the example demonstrates how to do this with the id record, and as you may know the id records needs to be unique. Unfortunately the unique id of the table that populates the primary grid is unique to that table. How can I go about populating the subgrid with data in this scenario?
My thoughts are:
1. Using a js function onSelectRow to get a specific column in ColModel and set that as the id for the sub grid url.
2. Somehow approach this at the database level and somehow perform a join on two tables using unique data on table 1 to join with table 2. I don't know how this could be done though.
09:03

28/12/2009

I figured this problem out after closing my eyes and thinking real hard for 3 minutes. I am not sure anyone else will need this information but I am going to share it just in case
php
$responce->rows[$i]['id']=$row[computer_name].$row[record];
the db column computer_name exists in other tables in my db design and this column isn't unique on this particular table so I needed to use an autoincrementing column in this case record and concatenate it to the computer_name becoming one string, thus becoming a unique number!
javascript
onSelectRow: function(ids) {
if(ids == null && ids != ids)
{
ids=0;
if($(”#masterSubGrid”).jqGrid('getGridParam','records') >0 )
{
$(”#masterSubGrid”).jqGrid('setGridParam',{url:”store_master_detail_subgrid.php?q=1&id=”+ids.substring(0,4),page:1});
$(”#masterSubGrid”).jqGrid('setCaption',”Viewing Compuuters for Store: “+ids.substring(0,4))
.trigger('reloadGrid');
}
} else {
$(”#masterSubGrid”).jqGrid('setGridParam',{url:”store_master_detail_subgrid.php?q=1&id=”+ids.substring(0,4),page:1});
$(”#masterSubGrid”).jqGrid('setCaption',”Viewing Computers for Store: “+ids.substring(0,4))
.trigger('reloadGrid');
}
}
and substring to save the day, since I don't really care about all the information contained in id I need to use substring to extract the exact information I need which happens to be the first 4 characters. because I made it the first 4 characters in my php code $row[computer_name].$row[record];
Most Users Ever Online: 715
Currently Online:
76 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66