ivan bishop
ivan bishop

Reputation: 1

empty grid returned to JQgrid 4.1.1 with Jquery 1.5.2

I am having real difficulty getting data to show in my grid. Queries can be used to retricve data by firstname, lastname or a 'serialnumber'

The HTML looks like

    <script src="lib/jquery/jquery-1.5.2.min.js" type="text/javascript" ></script>
     <script src="lib/jquery/jquery-ui.min.js" type="text/javascript"> </script>
    <script src="lib/jqgrid/i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="lib/jqgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
    <div id="search">
     <table id="list"></table>
     <div id="pager" ></div>
       </div>

The database and PHP are LOCAL for now and MYSQLi queries are getting the correct data everytime.

Javascript looks like

$('#list').jqGrid({
url:'http://localhost/ajax-search.php',
datatype: 'json',
postData: {
user: function() { return jQuery("input#username").val(); },
pass: function() { return jQuery("input#password").val(); },
firstname: function() { return jQuery("#firstname_label").val(); },
lastname: function() { return jQuery("#lastname_label").val(); },
number: function() { return jQuery("#number_label").val(); }
},
mtype: 'POST',
colNames:['id','First','Last', 'Number'],
colModel:[
{name: 'id',  index:'id',width:10,hidden:false},
{name: 'targetfirstname',  index:'targetfirstname',width:25},
{name: 'targetlastname',   index:'targetlastname',width:25},
{name: 'number',       index:'number', width:25},
],
rowNum:10,
width:340,
height: 25,
setGridHeight:45,
shrinkToFit:true,
rowList:[10,20,30],
imgpath: 'lib/jquery/themes/base/images',
pager: $('#pager'),
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Edit records",
});

The PHP/MYSQL (prepared statemenst in use) looks like

$response = new stdClass();
$response->page =      $page;           // current page
$response->total =     $total_pages;    // total pages
$response->records =   $numrows;        // total records
                $stmt2->execute()
                || fail('MySQL execute', $db->error);
                $stmt2 -> bind_result($seltargetfirstname,$seltargetlastname,$selnumber )
                || fail('MySQL bind_result', $db->error);

$i=0;
while($row = $stmt2->fetch()) {
  fwrite($fh2,"\n I is $i \n");
  $response->rows[$i]['id']=$i;
  $response->rows[$i]['cell']=array($i,$seltargetfirstname,$seltargetlastname,$selnumber);
  $i++;
  fwrite($fh2, "\nTO ENCODER $i $seltargetfirstname $seltargetlastname $selnumber\n");
}

echo json_encode($response);

What I see is

[1] NO Apache/PHP/JSON encode or MYSQL  errors
[2] I can write out the returned MYSQLI fetch values to a file, all look good
[3] I generate a row number as I dont use/need these in my schema
[4] The grid generates in JQGRID and I can sort and see my query re-execute but  NO data
    in the grid at all..

ANY ideas appreciated......

Upvotes: 0

Views: 666

Answers (1)

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18344

Use firebug's net console (for Firefox) while you start the request to see if you're getting the json from the server. Tell us what happens after that.

Hope this helps. Cheers

Upvotes: 0

Related Questions