sunqiusong 2009-04-28 11:23
浏览 195
已采纳

ext无法显示后台的json数据(急)

JAVA代码如下:
response.setContentType("text/xml; charset=UTF-8");
String query = request.getParameter("query");
XS03Service xs03Service = ServiceFactory.getInstance().getXS03Service();
List list = xs03Service.getSalesList(query);
StringBuffer jsonStr = new StringBuffer("");
jsonStr.append("{data:");
jsonStr.append("[\r\n");
for(Iterator iterator=list.iterator();iterator.hasNext();){
AbstractYwSalesmain sales = (AbstractYwSalesmain)iterator.next();
//jsonStr.append("{id:").append("'"+sales.getSalesid()+"',");
jsonStr.append("{salesid:").append("'"+stringNullProcess(sales.getSalesid())+"',");
jsonStr.append("poser:").append("'"+stringNullProcess(sales.getPoser())+"',");
jsonStr.append("netprice:").append(sales.getNetamount()+",");
jsonStr.append("mrsaleprice:").append(floatNullProcess(sales.getMrsaleprice())+",");
jsonStr.append("amount:").append(sales.getAmount()+",");
jsonStr.append("scalar:").append(sales.getScalar()+",");
jsonStr.append("balance:").append(sales.getBalance()+",");
if(iterator.hasNext())
jsonStr.append("updatetime:").append("'"+sales.getUpdatetime()+"'},");
else
jsonStr.append("updatetime:").append("'"+sales.getUpdatetime().toString().substring(0, 10)+"'}");

    }
    jsonStr.append("\r\n]}");
    log.debug(jsonStr);
    PrintWriter out = response.getWriter();
    out.println(jsonStr.toString());
    out.flush();
    out.close();

下面是JSP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html; charset=utf-8" %>

<%
String query = (String)request.getAttribute("query");
//String returnid = (String)request.getAttribute("returnid");

%>
<br> this.focus();<br> var gridmorebook;<br> Ext.onReady(function(){<br> var proxy=new Ext.data.HttpProxy( {url:&#39;/rmbcs/xs03.op?method=salesList&amp;query=&lt;%=query%&gt;&#39;}); <br> // create the data storenew Ext.data.Store<br> var reader = new Ext.data.JsonReader({<br> // idProperty:&#39;id&#39;,<br> fields: [<br> //{name: &#39;id&#39;,type:&#39;string&#39;},<br> {name: &#39;salesid&#39;,type:&#39;string&#39;},<br> {name: &#39;poser&#39;,type:&#39;string&#39;},<br> {name: &#39;netprice&#39;, type: &#39;string&#39;},<br> {name: &#39;mrsaleprice&#39;, type: &#39;string&#39;},<br> {name: &#39;amount&#39;, type: &#39;string&#39;},<br> {name: &#39;scalar&#39;, type: &#39;string&#39;},<br> {name: &#39;balance&#39;, type: &#39;string&#39;},<br> {name: &#39;updatetime&#39;, type: &#39;string&#39;}<br> ]<br> });<br> var store2 = new Ext.data.Store({<br> proxy:proxy,<br> reader:reader<br> });<br> // alert(store2.length());<br> store2.load();<br> alert(store2);<br> // create the Grid<br> gridmorebook = new Ext.grid.GridPanel({<br> //deferRowRender:false,<br> store: store2,<br> columns: [<br> {header: &quot;销售单编号&quot;, width: 160, sortable: true, dataIndex: &#39;salesid&#39;,align:&#39;center&#39;},<br> // {id:&#39;salesid&#39;,header: &quot;销售单编号&quot;, width: 160, dataIndex: &#39;id&#39;,align:&#39;center&#39;},<br> {header: &quot;收银员&quot;, width: 120, dataIndex: &#39;poser&#39;,align:&#39;center&#39;},<br> {header: &quot;销售码洋&quot;, width: 100, dataIndex: &#39;netprice&#39;,align:&#39;center&#39;},<br> {header: &quot;销售折扣&quot;, width: 120, dataIndex: &#39;mrsaleprice&#39;,align:&#39;center&#39;},<br> {header: &quot;销售实洋&quot;, width: 100, dataIndex: &#39;amount&#39;,align:&#39;right&#39;},<br> {header: &quot;销售数量&quot;, width: 100, dataIndex: &#39;scalar&#39;,align:&#39;right&#39;},<br> {header: &quot;支付方式&quot;, width: 80, dataIndex: &#39;balance&#39;,align:&#39;right&#39;},<br> {header: &quot;销售日期&quot;, width: 80, dataIndex: &#39;updatetime&#39;,align:&#39;right&#39;}</p> <pre><code> ], height:400, width:860, header: false }); gridmorebook.render(&#39;gridDiv2&#39;); /** gridmorebook.store.on(&quot;load&quot;,function(){ alert(store2.length); gridmorebook.getSelectionModel().selectRow(1); gridmorebook.getSelectionModel().selectFirstRow(); gridmorebook.getView().focusEl.focus(); } )**/ //gridmorebook.getView().focusEl.focus(); /** gridmorebook.on(&quot;keydown&quot;,function(e){ if(e.keyCode==13){ Ext.Ajax.request({ url: &#39;/rmbcs/xs03.op?method=itemthinsert&#39;, success: function(data){ if(data.responseXML.getElementsByTagName(&quot;enough&quot;)[0].firstChild.data==0){ alert(&#39;此商品可退数量不足!&#39;); }else{ parent.grid.getStore().reload(); parent.netamount.value=data.responseXML.getElementsByTagName(&quot;netamount&quot;)[0].firstChild.data; parent.amount.value=data.responseXML.getElementsByTagName(&quot;mianamount&quot;)[0].firstChild.data; parent.partid.focus(); parent.partid.select(); } parent.win.destroy(); }, failure: function(data){ alert(&quot;false&quot;); }, headers: { &#39;my-header&#39;: &#39;foo&#39; }, params: { id: gridmorebook.getSelectionModel().getSelected().data.id,scalar:1} }); } })**/ </code></pre> <p>});</p> <p>

后台out的数据怎么不能在前面显示?
[color=red] debug输出如下:
{data:[
{salesid:'2009041509285702',poser:'',netprice:5.0,mrsaleprice:0,amount:5.0,scalar:1,balance:现金支付,updatetime:'2009-04-15'}
]}[/color]

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥30 AndroidBench&eMMC内存测试速度&Android
      • ¥15 W10 文件共享失败 怎么解决
      • ¥20 b站私信完整导出的方法
      • ¥15 边界图中的x、y轴解释
      • ¥30 如何用matlab求解复杂方程
      • ¥15 VUE TS中怎么调用第三方js
      • ¥15 Activiti如何将值传入textValue
      • ¥20 在linux里安装lummps时 在make mpi里找不到rpc
      • ¥25 python先到先得调度和轮询调度
      • ¥15 SDK Manager闪退