欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

jqgrid显示不了数据

程序员文章站 2022-06-06 23:43:21
...
jqgrid显示不数据,请各位大大帮忙看看
无标题文档


 0) {			$total_pages = ceil($count / $limit);		} else {			$total_pages = 0;		}		if ($page > $total_pages)			$page = $total_pages;		$start = $limit * $page - $limit;		if ($startpage = $page;		$responce->total = $total_pages;		$responce->records = $count;		$i = 0;		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {			$responce->rows[$i]['id'] = $row[id];			$opt = "修改";			$responce->rows[$i]['cell'] = array (				$row['sn'],				$row['title'],				$row['size'],				$row['os'],				$row['charge'],				$row['price'],				$opt			);			$i++;		}		//print_r($responce);		echo json_encode($responce);								function uniDecode($str, $charcode) {	$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", toUtf8, $str);	return mb_convert_encoding($text, $charcode, 'utf-8');}function toUtf8($ar) {	foreach ($ar as $val) {		$val = intval(substr($val, 2), 16);		if ($val 


回复讨论(解决方案)

$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", toUtf8, $str);
应为
$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", 'toUtf8', $str);

xuzuning大大, 'toUtf8'加两个单引号,我加了不行,我不知道是不是文件的编码有问题,本地测试的时候,有些Js文件我改一下编码,就显不了数据库的数据了

另外我直接输出结果


 0) {			$total_pages = ceil($count / $limit);		} else {			$total_pages = 0;		}		if ($page > $total_pages)			$page = $total_pages;		$start = $limit * $page - $limit;		if ($startpage = $page;		$responce->total = $total_pages;		$responce->records = $count;		$i = 0;		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {			$responce->rows[$i]['id'] = $row["id"];			$opt = "修改";			$responce->rows[$i]['cell'] = array ($row['sn'],$row['title'],$row['size'],	$row['os'],	$row['charge'],	$row['price'],$opt);			$i++;		}				echo json_encode($responce);?>









{"page":1,"total":2,"records":"14","rows":[{"id":"1","cell":["1001","\u82f9\u679ciPhone 4S\uff0816GB\uff09","3.5\u82f1\u5bf8 960x640\u50cf\u7d20 ","iOS 5.0","1420mAh","5150","\u4fee\u6539"]},{"id":"2","cell":["1002","\u4e09\u661fI9100 GALAXY SII\uff0816GB\uff09","4.3\u82f1\u5bf8 800x480\u50cf\u7d20 ","Android OS 2.3 ","1650mAh ","3790","\u4fee\u6539"]},{"id":"3","cell":["1003","HTC G11\uff08Incredible S\uff09","4\u82f1\u5bf8 800x480\u50cf\u7d20","Android OS 2.2 ","1450mAh","2232","\u4fee\u6539"]},{"id":"4","cell":["1004","\u9b45\u65cfM9\uff088GB\uff09","3.5\u82f1\u5bf8 960x640\u50cf\u7d20","Android OS 2.3 ","1370mAh","1729","\u4fee\u6539"]},{"id":"5","cell":["1005","\u5c0f\u7c73M1\uff08MIUI\uff09","4\u82f1\u5bf8 854x480\u50cf\u7d20","MIUI+\u539f\u751fAndroid","1930mAh","1999","\u4fee\u6539"]},{"id":"6","cell":["1006","\u8bfa\u57fa\u4e9aC5-03","3.2\u82f1\u5bf8 640x360\u50cf\u7d20 ","Symbian S60V5","1000mAh","1164","\u4fee\u6539"]},{"id":"7","cell":["1007","\u6469\u6258\u7f57\u62c9XT910\uff08DROID RAZR\uff09","4.3\u82f1\u5bf8 960x540\u50cf\u7d20 ","Android OS 2.3 ","1780mAh","3700","\u4fee\u6539"]},{"id":"8","cell":["1008","\u8bfa\u57fa\u4e9aN8","3.5\u82f1\u5bf8 640x360\u50cf\u7d20 ","Symbian^3 ","1200mAh","2302","\u4fee\u6539"]},{"id":"9","cell":["1009","\u534e\u4e3aU8860 Honor\uff08\u8363\u8000\uff09","4\u82f1\u5bf8 854x480\u50cf\u7d20","Android OS 2.3","1930mAh","1889","\u4fee\u6539"]},{"id":"10","cell":["1010","\u4e09\u661fW999","3.5\u82f1\u5bf8 800x480\u50cf","Android OS 2.3 ","1500mAh ","12340","\u4fee\u6539"]},{"id":"11","cell":["1011","\u9177\u6d3eN900+","3.2\u82f1\u5bf8 480x320\u50cf ","Windows CE 6.0 ","1500mAh ","6180","\u4fee\u6539"]},{"id":"12","cell":["1012","\u9ed1\u83939800\uff08Torch\uff09","3.2\u82f1\u5bf8 480x360\u50cf\u7d20","BlackBerry OS 6","1300mAh","4900","\u4fee\u6539"]}]}

可以显示了,我把那些转换函数都删除了

请参考jqGrid中文demo:http://blog.mn886.net/jqGrid/