控制器代码:
public function index(){
$product=M('product')->select();
$qty=count(M('product')->select());
$result["total"]=$qty;
$result["rows"]=$product;
echo json_encode($result);
//$json_string=json_encode($product);
//$obj=json_decode($json_string);
//$this->ajaxReturn($result);
//dump($product);die;
//$json='{"total":'.$total.',"rows":'.json_encode($userlist).'}';
$this->display();模板代码:<table id="dg" title="My Users" class="easyui-datagrid" style="width:700px;height:250px"
url="{:U('Index.php/Index/Product/index')}"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="productID" width="50">subjectcode</th>
<th field="productName" width="250">Question</th>
</tr>
</thead>
</table>结果easyUI的标题可以显示,但数据就是出不来,不知道是什么原因? 最佳答案