過程描述:頁面 A輸入參數,進入controller進行邏輯處理並生成json數據,然後通過
MVC返回json數據,並對頁面A相關easyui datagrid表格進行數據展示。
問題:easyui datagrid不現實數據,且頁面不報錯,調試能看到json數據。
頁面代碼:
<button id="myb" class="easyui-linkbutton c6" type="button"
onclick="test()" >測試</button>
function test(){
jq('#tt').datagrid({
title:'DataGrid - DetailView',
width:500,
height:250,
remoteSort:false,
singleSelect:true,
nowrap:false,
fitColumns:true,
type:"POST",
url:'/store/saleout/getjson',
columns:[[
{field:'product_name',title:'Item ID',width:80},
{field:'numbers',title:'Product ID',width:100,sortable:true},
{field:'price',title:'List Price',width:80,align:'right',sortable:true},
{field:'buyer',title:'Unit Cost',width:80,align:'right',sortable:true}
]]
});
alert("333");
}
調試顯示數據:{"rows":[{"product_name":"土豆","numbers":2,"price":40,"buyer":"A","style":"A","type":"WU","saleoutdate":"2015-3-31"}],"total":1}
請教一下:什麼原因導致 easyui datagrid數據不顯示?不報錯,不知道到底從哪裡入手,困擾了不短時間,多謝!!
頁面完整代碼如下,調試數據截圖在附件中。
![![圖片說明](http://img.ask.csdn.net/upload/201505/31/1433004879_544586.png)圖片說明](http://img.ask.csdn.net/upload/201505/31/1433004871_778225.png)
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en">
<jsp:include page="../fragments/staticFiles.jsp" />
<jsp:include page="../fragments/BootStrapFiles.jsp"/>
<head>
<meta charset="utf-8">
<title>saleout</title>
<script type="text/javascript">
var jq = $.noConflict();
function test(){
jq('#tt').datagrid({
title:'DataGrid - DetailView',
width:500,
height:250,
remoteSort:false,
singleSelect:true,
nowrap:false,
fitColumns:true,
type:"POST",
url:'/store/saleout/getjson',
columns:[[
{field:'product_name',title:'Item ID',width:80},
{field:'numbers',title:'Product ID',width:100,sortable:true},
{field:'price',title:'List Price',width:80,align:'right',sortable:true},
{field:'buyer',title:'Unit Cost',width:80,align:'right',sortable:true}
]]
});
alert("333");
}
jq(document).ready(function(){
jq("#ajax_pos").click(
function (){alert("test");
jq.ajax({url:"<spring:url value="/saleout/precheck.html"/>",
data:jq("#search_form").serialize(),
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
type:"POST",
success: function(data){
// jq("#tt").datagrid("load");
if( window.confirm(" 添加記錄成功,是否繼續添加?")){
// location.reload();
// alert(data.toString());
}else{
location.href="<spring:url value="/menu" htmlEscape="true"/>";
}
},
error:function(data){alert("數據失敗!"+data);},
});
});
});
</script>
<style>
ul {
margin: 0;
width: 100%;
}
li {
margin: left;
float: left;
width: 100%;
}
</style>
</head>
<body>
<div id="headmenu">
<jsp:include page="../saleOut/saleoutMenu.jsp"/>
</div>
<p></p>
<table id="tt"></table>
<button id="myb" class="easyui-linkbutton c6" type="button"
onclick="test()" >測試</button>
<div id="ajax_form" align="center" >
<form:form modelAttribute="saleout" id="search_form" method="post">
<fieldset>
<div id="product_name" align="left">
<label class="control-label">產品名稱: </label>
<form:input path="product_name" size="30" maxlength="80" />
</div>
</fieldset>
</form:form>
<div id="_buttons">
<button id="ajax_pos" class="easyui-linkbutton c6" type="button"
style="width: 80px; height: 35px" >提交</button>
</div>
</div>
</body>
</html>
什麼版本的easyui。。1.3.2測試你的代碼沒問題。。你的連表頭都沒有,是不是導入的樣式有沖突什麼的,開發工具看下表頭都有什麼樣式
<jsp:include page="../fragments/BootStrapFiles.jsp"/>
你導入bootstrap框架了?