2010-05-18 2 views
0

i ont une page post2.php qui imprime le tableau JSON commeproblème Flexigrid dans zend

{ 
page: 1, 
total: 239, 
rows: [ 
{id:'239',cell:['239','ZW','ZIMBABWE','Zimbabwe','ZWE','716']}, 
{id:'238',cell:['238','ZM','ZAMBIA','Zambia','ZMB','894']}, 
{id:'237',cell:['237','YE','YEMEN','Yemen','YEM','887']}, 
{id:'236',cell:['236','EH','WESTERN SAHARA','Western Sahara','ESH','732']}, 
{id:'235',cell:['235','WF','WALLIS AND FUTUNA','Wallis and Futuna','WLF','876']}, 
{id:'234',cell:['234','VI','VIRGIN ISLANDS, U.S.','Virgin Islands, U.s.','VIR','850']}, 
{id:'233',cell:['233','VG','VIRGIN ISLANDS, BRITISH','Virgin Islands, British','VGB','92']}, 
{id:'232',cell:['232','VN','VIET NAM','Viet Nam','VNM','704']}, 
{id:'231',cell:['231','VE','VENEZUELA','Venezuela','VEN','862']}, 
{id:'230',cell:['230','VU','VANUATU','Vanuatu','VUT','548']}] 
} 

et vues zend je suis en train de faire comme

$(document).ready(function(){ 

     $("#flex1").flexigrid 
         (
         { 
         url: '/public/**post2.ph**p', 
         dataType: 'json', 
         colModel : [ 
           {display: 'ID', name : 'id', width : 40, sortable : true, align: 'center'}, 
           {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'}, 
           {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'}, 
           {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'}, 
           {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true}, 
           {display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'} 
           ], 
         buttons : [ 
           {name: 'Add', bclass: 'add', onpress : test}, 
           {name: 'Delete', bclass: 'delete', onpress : test}, 
           {separator: true}, 
           {name: 'A', onpress: sortAlpha}, 
           ], 
         searchitems : [ 
           {display: 'ISO', name : 'iso'}, 
           {display: 'Name', name : 'name', isdefault: true} 
           ], 
         sortname: "id" 
         sortorder: "asc", 
         usepager: true, 
         title: 'Countries', 
         useRp: true, 
         rp: 10, 
         showTableToggleBtn: true, 
         width: 700, 
         height: 255 
         } 
         ); 

}); 

ceci affiche l'Flexigrid mise en page bien .. mais n'obtient jamais le data.it continue de dire le traitement. Y at-il un problème dans le tableau json ou dans l'appel flexigrid ... ou dans zend avec json.

des suggestions pour essayer pour ce problème?

J'ai essayé comme ça aussi

$.post("/public/server_processing1.php",{},function(data){ 
alert('hai'); 
alert(data); 
}, "json"); 

et son même pas alerte hai ..

complet code post2.php est comme ce

<? 
error_reporting(1); 
function runSQL($rsql) { 
     $hostname = "localhost"; 
     $username = "root"; 
     $password = "root"; 
     $dbname = "hms1"; 
     $connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database"); 
     $db = mysql_select_db($dbname); 
     $result = mysql_query($rsql) or die ('test'); 
     return $result; 
     mysql_close($connect); 
} 

function countRec($fname,$tname,$where) { 
$sql = "SELECT count($fname) FROM $tname $where"; 
$result = runSQL($sql); 
while ($row = mysql_fetch_array($result)) { 
return $row[0]; 
} 
} 
$page = $_POST['page']; 
$rp = $_POST['rp']; 
$sortname = $_POST['sortname']; 
$sortorder = $_POST['sortorder']; 

if (!$sortname) $sortname = 'pa_name'; 
if (!$sortorder) $sortorder = 'desc'; 
       if($_POST['query']!=''){ 
         $where = "WHERE `".$_POST['qtype']."` LIKE '%".$_POST['query']."%' "; 
       } else { 
         $where =''; 
       } 
       if($_POST['letter_pressed']!=''){ 
         $where = "WHERE `".$_POST['qtype']."` LIKE '".$_POST['letter_pressed']."%' "; 
       } 
       if($_POST['letter_pressed']=='#'){ 
         $where = "WHERE `".$_POST['qtype']."` REGEXP '[[:digit:]]' "; 
       } 
$sort = "ORDER BY $sortname $sortorder"; 

if (!$page) $page = 1; 
if (!$rp) $rp = 10; 

$start = (($page-1) * $rp); 

$limit = "LIMIT $start, $rp"; 
$sql = "SELECT pa_id,pa_name,pa_pd_patient_id,pa_name FROM patient_appointment $where $sort $limit"; 
$result = runSQL($sql); 

$total = countRec('pa_id','patient_appointment',$where); 

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache"); 
header("Content-type: text/x-json"); 
$json = ""; 
$json .= "{\n"; 
$json .= "page: $page,\n"; 
$json .= "total: $total,\n"; 
$json .= "rows: ["; 
$rc = false; 
while ($row = mysql_fetch_array($result)) { 
if ($rc) $json .= ","; 
$json .= "\n{"; 
/*$json .= "cell:['".$row['pa_name']."'"; 
$json .= ",'".addslashes($row['time'])."'"; 
$json .= ",'".addslashes($row['pa_um_id'])."'"; 
$json .= ",'".addslashes($row['pa_pd_patient_id'])."']";*/ 
$json .= "id:'".$row['pa_id']."',"; 
$json .= "cell:['".$row['pa_id']."','".$row['pa_name']."'"; 
$json .= ",'".addslashes($row['pa_pd_patient_id'])."']"; 

$json .= "}"; 
$rc = true; 
} 
$json .= "]\n"; 
$json .= "}"; 
echo $json; 
?> 

Répondre

0

Je devine que vous » re en utilisant le navigateur IE. Si c'est le cas, IE n'aime pas le conteneur <div id="flex1"></div>. Changez-le en <table id="flex1"></table> et tout devrait fonctionner.