I can get the grid to work if I have it pull a JSON file that I create with PHP, but if I return the results straight to the ListGrid from PHP, the “getting results from server” message never goes away on the page.
Here is my HTML page:
<html>
<body>
<SCRIPT>var isomorphicDir='smartClient/isomorphic/';</SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_Core.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_Foundation.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_Containers.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_Grids.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_Forms.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/system/modules/ISC_DataBinding.js'></SCRIPT>
<SCRIPT SRC='smartClient/isomorphic/skins/SmartClient/load_skin.js'></SCRIPT>
<script>
isc.XJSONDataSource.create({
ID:'employees',
dataFormat:'json',
dataURL:'http://localhost/hb/sugar/sc_test.php?json=yes',
fields:[
{title:'First Name', name:'first_name'},{title:'Last Name', name:'last_name'}
]
});
isc.ListGrid.create({
ID: 'myGrid',
width: '',
height: '',
dataSource: 'employees',
autoDraw:true,
alternateRecordStyles:true,
showAllRecords:true,
position:'relative',
autoFetchData: true
});
</script>
</body>
</html>
Here is the PHP page that creates the JSON data (also creates the HTML):
<?
require_once('include/inc/bh_db.inc.php');
require_once('smart_client.inc.php');
extract($_REQUEST);
if($json=='yes')
{
// return the data in json format
$sql = "select first_name,last_name from users order by last_name,first_name limit 5";
$rs = dbCall($sql,false);
$c = rs2json($rs);
//string2file('employees.js',$c,'w');
print $c;
exit();
}
print "<html>
<body>
";
print scIncludes();
$fields = array("First Name"=>"first_name","Last Name"=>"last_name");
print "<script>\n";
print scCreateDataSource('employees',"http://localhost/hb/sugar/sc_test.php?json=yes",$fields);
print scCreateListGrid('myGrid','','','employees','true');
print "</script>\n";
print "
</body>
</html>
";
?>
Here is the JSON output from the script in the dataURL:
[ {first_name:'Paul', last_name:'Abfalter'}, {first_name:'Roy', last_name:'Abshier'}, {first_name:'Roy', last_name:'Acrea'}, {first_name:'John', last_name:'Adams'}, {first_name:'Nathan', last_name:'Adamson'} ]
Can someone please tell me what I am doing wrong?
Thanks,
Scott Hathaway