Forum



14:59

27/11/2012

Hello, I'm new to this jquery plugin. I decided to use it among many others because this one looks the most
powerful. However I'm having problems to get it working.
First of all, as said in the topic, since the content will be served from the server (PHP), and I want to use it to
display different lists of items, I need that both properties colNames and colModel will be served dynamically.
So, this is how I set it up in a js file:
$(document).ready(function() { $("#listing").jqGrid({ datatype: "clientSide", height: 500, colNames: namesList, colModel: modelList, multiselect: true, viewrecords: true, caption: "Test" }); });
Here's an example in PHP of an item type whose records must be listed. I set its corresponding column
names and how will they be displayed:
$colNames = array('Id', 'Title', 'Featured', 'Language', 'Date created', 'Date modified',
'Date published', 'Status'); $colModel = array( array('name' => 'id_article', 'id' => 'id_article', 'width' => 60, 'sorttype' => 'int'), array('name' => 'title', 'id' => 'title', 'width' => 450, 'sorttype' => 'text'), array('name' => 'featured', 'id' => 'featured', 'width' => 60, 'sorttype' => 'int'), array('name' => 'language', 'id' => 'language', 'width' => 60, 'sorttype' => 'text'), array('name' => 'date_c', 'id' => 'date_c', 'width' => 120, 'sorttype' => 'date'), array('name' => 'date_m', 'id' => 'date_m', 'width' => 120, 'sorttype' => 'date'), array('name' => 'date_p', 'id' => 'date_p', 'width' => 120, 'sorttype' => 'date'), array('name' => 'status', 'id' => 'status', 'width' => 60, 'sorttype' => 'int') );
This is how I dynamically create the variables I need for colNames, colModel and the data to display
(enclosed with script tags):
var namesList = < ?php echo json_encode($colNames) ? >, modelList = < ?php echo json_encode($colModel) ? >, data = < ?php echo json_encode($lista) ? > for(var i = 0; i <= datos.length; i++) { $('#listing').addRowData(i+1, data[i]); }
With this all configured, I just get to build the background of the grid with the column names.
No data is displayed. Could you please help me?
Most Users Ever Online: 715
Currently Online:
45 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