Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Subgrid not displaying data
14/05/2011
00:20
Avatar
sagana
Australia
Member
Members
Forum Posts: 16
Member Since:
20/08/2009
sp_UserOfflineSmall Offline

The grid works. The + opens the subgrid correctly and displays the header row. The correct number of rows display in the subgrid but are empty despite the correct json being created as displayed in firebug.

Code snippet for grid:-

// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
// We suppose that mytable exists in your database
$grid->SelectCommand = "select uid,lastname,firstname,phonehome,phonework,mobile from students ".$where;

// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('students/getstudents.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
    "caption"=>"Students and their Courses",
    "rowNum"=>16,
    "sortname"=>"lastname",
    "rowList"=>array(16,30,50),
    "height"=>354,
    "width"=>900
    ));

$grid->addCol(array("name"=>"act"),"first");

// Change some property of the field(s)
$grid->setColProperty("uid", array("label"=>"ID", "width"=>20, "hidden"=>true));
$grid->setColProperty("act", array("label"=>"Actions", "width"=>90));
$grid->setColProperty("lastname", array("label"=>"Last Name", "width"=>200));
$grid->setColProperty("firstname", array("label"=>"First Name", "width"=>150));
$grid->setColProperty("phonehome", array("label"=>"Phone Home", "width"=>150));
$grid->setColProperty("phonework", array("label"=>"Phone Work", "width"=>150));
$grid->setColProperty("mobile", array("label"=>"Mobile", "width"=>150));

$grid->setSubGrid("students/getcourses.php",
        array('Course','Status','Year','Semester'),
        array(300,150,40,50),
        array('left','left','right','center'));

Code for subgid

require_once '../includes/jquery/jq-config.php';
// include the jqGrid Class
require_once "../includes/jquery/php/jqGrid.php";
// include the PDO driver class
require_once "../includes/jquery/php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);

// Get the needed parameters passed from the main grid
$rowid = jqGridUtils::Strip($_REQUEST["id"]);
if(!$rowid) die("Missed parameters");

// Create the jqGrid instance
$grid = new jqGrid($conn);
// Write the SQL Query
$grid->SubgridCommand = "select courses.course, studcourse.status, courses.year, courses.semester from studcourse, courses where studcourse.studentno =".$rowid." and studcourse.courseno = courses.uid";

// set the ouput format to json
$grid->dataType = 'json';
// Use the build in function for the simple subgrid
$grid->querySubGrid(array(&$rowid));
$conn = null; 

json returned by subgrid code

{"rows":[{"course":"CSBM ","status":"Query","year":"2009","semester":"A"},

{"course":"FSB ","status":"Query","year":"","semester":""}]}

Can someone please tell me why these records are not being displayed in the subgrid.

16/05/2011
10:57
Avatar
crilla86
Member
Members
Forum Posts: 8
Member Since:
10/05/2011
sp_UserOfflineSmall Offline

Hi. i'm using the subgrid too.

Maybe your problem is related to json because you return a bad json.

The correct formatted json that you return should be like this:

{"rows":[{"cell":[
"CSBM ","Query","2009","A"

]},
{"cell":[
"FSB ","Query","",""

]}]}.


Ps: sorry for my bad english.
25/05/2011
11:31
Avatar
sagana
Australia
Member
Members
Forum Posts: 16
Member Since:
20/08/2009
sp_UserOfflineSmall Offline

I have the subgrid working in other sites and see the json returned is in the same format as I describe above so I am stumped as to why it is not working here. Besides, the only control I have over the json produced is to tell the grid $grid->dataType = 'json'; . I cannot see what is different that is stopping it from working.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
40 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information