var grid = null; $(function () { grid = $("#maingrid4").ligerGrid({ columns: [ { display: '主键', name: 'CustomerID', width: 120 } ], pageSize: 10, //where: f_getWhere(), //data: $.extend(true, {}, jsonObj), // url: 'ajaxFile/orderHandler.ashx?flag=getList', width: '100%', height: '100%' }); //$("#pageloading").hide(); });
上面是前端,
后段返回的数据格式为
{ "Rows":[{ "CustomerID": 123 }],"Total": 1}
绑定不成功,空白页面,请指教,我错在哪里啦?在线等
点开控制台看看那里出错了
用上面浏览器查?
用什么浏览器查?
@iisp: 谷歌 ie 都可以啊,一般的浏览器都能查啊,就是看看你的脚本报错了没
@博客¥: 没有
@iisp: 是不是没引用jquery
@博客¥:引用了3.2
@iisp: 代码太少,看不出来是那里出的问题
@博客¥:
<script src="../jquery/ligerui2/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="../jquery/ligerui2/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="../jquery/ligerui/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
@iisp: 整个页面的啊
@博客¥:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="list.aspx.cs" Inherits="project.order.list1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="../jquery/ligerui/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> <script src="../jquery/ligerui/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="../jquery/ligerui/lib/ligerUI/js/core/base.js" type="text/javascript"></script> <script src="../jquery/ligerui/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script> <script type="text/javascript"> var grid = null; $(function () { $("#maingrid4").ligerGrid({ columns: [ { display: '主键', name: 'CustomerID', width: 120 } ], pageSize: 10, //where: f_getWhere(), //data: $.extend(true, {}, jsonObj), // url: '../ajaxFile/orderHandler.ashx?flag=getList', width: '100%', height: '100%' }); }); </script> </head> <body> <form id="form1" runat="server"> <div id="maingrid4" style="margin:0; padding:0"></div> <div style="display:none;"></div> </form> </body> </html>
@博客¥:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Text; namespace project.ajaxFile { /// <summary> /// orderHandler 的摘要说明 /// </summary> public class orderHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string flag = "getList"; switch (flag) { case "getList": StringBuilder stbList = new StringBuilder(); stbList.Append("{ \"Rows\":["); stbList.Append("{ \"CustomerID\": \"123\" }"); stbList.Append("],\"Total\": \"1\"}"); context.Response.Write(stbList.ToString()); break; default: break; } } public bool IsReusable { get { return false; } } } }
@iisp: 我没用过url像你这么写的 我都是通过ajax返回数据后给columns赋值
@博客¥:OK 了,感谢你,启发我
@iisp: 我刚要试试你这么写可以不!不过我觉得这样应该不可以
@博客¥:
靠,绑定数据出来后,启用分页数据就不显示了,知道什么原因吗?
就加了这个 usePager: true,
@博客¥:
IE下不行,但是谷歌和火狐就OK喔,兼容性这么挫的
@iisp: 不是吧,我们做的ie下是可以用的,你在把前台代码发一下嘛
@博客¥:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="list.aspx.cs" Inherits="project.order.list1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="../jquery/ligerui/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> <script src="../jquery/ligerui/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="../jquery/ligerui/lib/ligerUI/js/core/base.js" type="text/javascript"></script> <script src="../jquery/ligerui/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script> <script type="text/javascript"> var grid = null; $(function () { $("#maingrid4").ligerGrid({ columns: [ { display: '主键', name: 'CustomerID', width: 120 } ], usePager: true, url: '../ajaxFile/orderHandler.ashx?flag=getList', width: '100%', height: '100%' }); }); </script> </head> <body> <form id="form1" runat="server"> <div id="maingrid4" style="margin:0; padding:0"></div> <div style="display:none;"></div> </form> </body> </html>
@iisp: pageSize: 10, 加上这个
@博客¥: 不行的,因为这个在插件内部有默认值的,就是10
@博客¥: 你也是.NET 开发的吗?是的话,加我的qq:1597400030,大家交个朋友