问题描述
- jqGrid 从后台能获取xml数据,但是前台grid数据就是显示不出来!页面有三条记录 5C
-
后台打印出来的数据:<Response> <transResult> <resultCode>1</resultCode> <resultInfoDesc>交易处理成功</resultInfoDesc> </transResult> <object class=""PageGrid""> <page>1</page> <total>1</total> <records>3</records> <data> <map> <PRODUCT__CHANNEL>Z250000034</PRODUCT__CHANNEL> <NAME>张三</NAME> <CONT__NO>QH41A8160122000086</CONT__NO> <START__ROWNUM__>1</START__ROWNUM__> <PAYMENT__NAME>在线支付</PAYMENT__NAME> <BIZE__CODE>101</BIZE__CODE> <ORDER__NO>925120160122016952</ORDER__NO> <HEART__STATUS>1</HEART__STATUS> <PLAN__CODE></PLAN__CODE> <RISK__CODE>41A8</RISK__CODE> <PAY__STATUS>3</PAY__STATUS> <ORG__FILE__PATH>http://127.0.0.1:8080/eservice/ebiz/client/insure.action?action=downloadPolicyFile&paras=emh1bW9iYW5uYW1lPUpLNDFBOCZwYXJhcz0xJTNkUUg0MUE4MTYwMTIyMDAwMDg2Jmlzc2lnbj10cnVl</ORG__FILE__PATH> </map> <map> <PRODUCT__CHANNEL>Z250000034</PRODUCT__CHANNEL> <NAME>张三</NAME> <CONT__NO>QH41A8160122000084</CONT__NO> <START__ROWNUM__>2</START__ROWNUM__> <PAYMENT__NAME>在线支付</PAYMENT__NAME> <BIZE__CODE>101</BIZE__CODE> <ORDER__NO>925120160122016950</ORDER__NO> <HEART__STATUS>1</HEART__STATUS> <PLAN__CODE></PLAN__CODE> <RISK__CODE>41A8</RISK__CODE> <PAY__STATUS>3</PAY__STATUS> <ORG__FILE__PATH>http://127.0.0.1:8080/eservice/ebiz/client/insure.action?action=downloadPolicyFile&paras=emh1bW9iYW5uYW1lPUpLNDFBOCZwYXJhcz0xJTNkUUg0MUE4MTYwMTIyMDAwMDg0Jmlzc2lnbj10cnVl</ORG__FILE__PATH> </map> <map> <PRODUCT__CHANNEL>Z250000034</PRODUCT__CHANNEL> <NAME>张三</NAME> <CONT__NO>QH41A8160122000085</CONT__NO> <START__ROWNUM__>3</START__ROWNUM__> <PAYMENT__NAME>在线支付</PAYMENT__NAME> <BIZE__CODE>101</BIZE__CODE> <ORDER__NO>925120160122016951</ORDER__NO> <HEART__STATUS>1</HEART__STATUS> <PLAN__CODE></PLAN__CODE> <RISK__CODE>41A8</RISK__CODE> <PAY__STATUS>3</PAY__STATUS> <ORG__FILE__PATH>http://127.0.0.1:8080/eservice/ebiz/client/insure.action?action=downloadPolicyFile&paras=emh1bW9iYW5uYW1lPUpLNDFBOCZwYXJhcz0xJTNkUUg0MUE4MTYwMTIyMDAwMDg1Jmlzc2lnbj10cnVl</ORG__FILE__PATH> </map> </data> </object></Response>查询SQL:select ord.order_no<!-- 订单时间 --> ord.cont_no <!-- 保单号 --> ord.product_Channel<!-- 渠道代码 --> insurance.risk_code <!-- 产品编码 --> insurance.plan_code<!-- 款别 --> appnt.name<!-- 投保人 --> ord.payment_name <!-- 支付方式 --> ord.bize_code<!-- 业务类型 --> ord.pay_status ord.HEART_STATUS <!-- 导入核心状态 --> cont.ORG_FILE_PATH <!--电子保单下载地址--> from ebiz_order ord <!-- 订单表 --> left join ebiz_appnt appnt <!-- 投保人表 --> on ord.order_no =appnt.order_no left join ebiz_payment pay <!-- 订单支付表 --> on ord.unno = pay.order_no and pay.is_delete =0 left join EBIZ_ORDER_INSURANCE insurance <!-- (订单险种表) --> on ord.order_no = insurance.order_no and insurance.is_delete =0 left join EBIZ_ELEC_CONT cont on ord.cont_no = cont.cont_no where ord.is_delete =0 <isNotNull property=""orderNo""> and ord.order_No = #orderNo# </isNotNull> <isNotNull property=""contNo""> and ord.cont_No = #contNo# </isNotNull> <isNotNull property=""channelName"">and ord.channel_Name = #channelName# </isNotNull> <isNotNull property=""productChannel"">and ord.product_Channel = #productChannel# </isNotNull> <isNotNull property=""riskCode"">and insurance.risk_Code= #riskCode# </isNotNull> <isNotNull property=""planCode"">and insurance.plan_Code= #planCode# </isNotNull> <isNotNull property=""name"">and appnt.name= #name# </isNotNull> <isNotNull property=""paymentName"">and sale.payment_Name= #paymentName# </isNotNull> <isNotNull property=""payStatus"">and ord.pay_Status= #payStatus# </isNotNull> <isNotNull property=""bizeCode"">and ord.bize_Code= #bizeCode# </isNotNull> <isNotNull property=""heartStatus"">and ord.heart_Status= #heartStatus# </isNotNull> <isNotNull property=""startDate""><![CDATA[and to_char(ord.modified_date'yyyy-mm-dd') >= #startDate#]]></isNotNull> <isNotNull property=""endDate"" ><![CDATA[and to_char(ord.modified_date 'yyyy-mm-dd') <= #endDate# ]]></isNotNull> order by ord.modified_date desc JS代码: $(""#jqGridTableId"").jqGrid({ url : Eservice.ctx +'/ebiz/inquire/contNoShow.action?action=getPolicyList&ajax=true' mtype : 'POST' postData : { heartStatus:$(""#heartStatus"").val() contNo:$(""#contNo"").val() riskCode:$(""#riskCode"").val() planCode:$(""#planCode"").val() channelName:$(""#channelName"").val() productChannel:$(""#productChannel"").val() name:$(""#name"").val() paymentName:$(""#paymentName"").val() bizeCode:$(""#bizeCode"").val() } datatype : ""xml"" colNames : ['保单号''渠道代码' '险种代码''款别' '投保人''支付方式' '导入核心状态' '业务类型''操作''订单号''支付状态''电子保单下载地址'] colModel : [{ name : 'CONT__NO' index : 'CONT__NO' align : 'center' sortable : false width: 70 }{ name : 'PRODUCT__CHANNEL' index : 'PRODUCT__CHANNEL' align : 'center' sortable : false width: 70 }{ name : 'RISK__CODE' index : 'RISK__CODE' align : 'center' formatter : 'date' sortable : false width: 55 }{ name : 'PLAN__CODE' index : 'PLAN__CODE' align : 'center' sortable : false width: 120 }{ name : 'NAME' index : 'NAME' align : 'center' sortable : false width: 55 }{ name : 'PAYMENT__NAME' index : 'PAYMENT__NAME' align : 'center' sortable : false width: 50/**/// formatter:function(valrec){ // var cname;// if(val=='1'){// cname=""已支付"";// }else if(val=='2'){// cname=""未支付"";// }else if(val=='3'){// cname=""支付失败"";// }// return cname; // } }{ name : 'HEART__STATUS' index : 'HEART__STATUS' align : 'center' sortable : false width: 50 /**/ /*formatter:function(valrec){ var cname; if(val=='1'){ cname=""已导入""; }else if(val=='2'){ cname=""未导入""; }else if(val=='3'){ cname=""导入失败""; } return cname; }*/ }{ name : 'BIZE__CODE' index : 'BIZE__CODE' align : 'center' sortable : false width: 75/* formatter:function(valrec){ var cname; if(val=='101'){ cname=""投保""; }else if(val=='102'){ cname=""退保""; }else if(val=='103'){ cname=""投保批改""; }else if(val=='104'){ cname=""异步返回""; }else if(val=='105'){ cname=""注销""; } return cname; }*/ }{ name : 'OPER' index : 'OPER' align : 'center' sortable : false width: 75 }{ name : 'ORDER__NO' index : 'ORDER__NO' hidden: true }{ name : 'PAY__STATUS' index : 'PAY__STATUS' hidden: true }{ name : 'ORG__FILE__PATH' index : 'ORG__FILE__PATH' hidden: true }] shrinkToFit : true rowNum : 10 rowList : [ 10 30 50 ] pager : '#jqGridPagerId' viewrecords : true xmlReader : { repeatitems : false root : ""object"" row : ""map"" page : 'page' total : 'total' records : 'records' } caption : ""保单信息"" height:'auto' gridComplete: function(){ //获得所有行的ID数组 var ids = $(""#jqGridTableId"").jqGrid('getDataIDs'); alert(ids); var contNo=$('#contNo').val(); for(var i=0;i < ids.length;i++){ var arr = $(""#jqGridTableId"").jqGrid('getRowData'ids[i]); alert(arr.ORDER__NO); var linkReq = ""<a href=# onclick='ContManage.winShowRequest('"" + arr.ORDER__NO + ""' '"" + arr.CONT__NO + ""')'>"" + arr.CONT__NO + ""</a>""; $(""#jqGridTableId"").jqGrid('setRowData'ids[i]{CONT__NO:linkReq}); var linkHis = ""<a href=# onclick='ContManage.winShowHis('"" + arr.ORDER__NO + ""' '"" + arr.CONT__NO + ""')'>"" + ""日志"" + ""</a>""; $(""#jqGridTableId"").jqGrid('setRowData'ids[i]{OPER:linkHis}); var linkDetail = ""<a href=# onclick='ContManage.winOpenOrder('"" + arr.ORDER__NO + ""' '"" + arr.CONT__NO + ""')'>"" + ""详情"" + ""</a>""; $(""#jqGridTableId"").jqGrid('setRowData'ids[i]{OPER:linkDetail}); var linkDown = ""<a href=""+arr.ORG__FILE__PATH+""?""+ arr.CONT__NO + ""'>"" + ""电子保单下载"" + ""</a>""; $(""#jqGridTableId"").jqGrid('setRowData'ids[i]{OPER:linkDown}); } } });
解决方案
浏览器 F12 看看数据response 到前台没有,如果数据回来了请确认,列名和返回的字段是否一一对应包括大小写。
解决方案二:
看看你的xml 格式返回时否正确。参考 http://www.trirand.com/blog/jqgrid/server.php?q=1&_search=false&nd=1453774981234&rows=10&page=1&sidx=id&sord=desc
<?xml version='1.0' encoding='utf-8'?><rows><page>1</page><total>2</total><records>13</records><userdata name='tamount'>3820.00</userdata><userdata name='ttax'>462.00</userdata><userdata name='ttotal'>4284.00</userdata><row id='13'><cell>13</cell><cell>2007-10-06</cell><cell><![CDATA[Client 3]]></cell><cell>1000.00</cell><cell>0.00</cell><cell>1000.00</cell><cell><![CDATA[]]></cell></row><row id='12'><cell>12</cell><cell>2007-10-06</cell><cell><![CDATA[Client 2]]></cell><cell>700.00</cell><cell>140.00</cell><cell>840.00</cell><cell><![CDATA[]]></cell></row><row id='11'><cell>11</cell><cell>2007-10-06</cell><cell><![CDATA[Client 1]]></cell><cell>600.00</cell><cell>120.00</cell><cell>720.00</cell><cell><![CDATA[]]></cell></row><row id='10'><cell>10</cell><cell>2007-10-06</cell><cell><![CDATA[Client 2]]></cell><cell>100.00</cell><cell>20.00</cell><cell>120.00</cell><cell><![CDATA[]]></cell></row><row id='9'><cell>9</cell><cell>2007-10-06</cell><cell><![CDATA[Client 1]]></cell><cell>200.00</cell><cell>40.00</cell><cell>240.00</cell><cell><![CDATA[]]></cell></row><row id='8'><cell>8</cell><cell>2007-10-06</cell><cell><![CDATA[Client 3]]></cell><cell>200.00</cell><cell>0.00</cell><cell>200.00</cell><cell><![CDATA[]]></cell></row><row id='7'><cell>7</cell><cell>2007-10-05</cell><cell><![CDATA[Client 2]]></cell><cell>120.00</cell><cell>12.00</cell><cell>134.00</cell><cell><![CDATA[]]></cell></row><row id='6'><cell>6</cell><cell>2007-10-05</cell><cell><![CDATA[Client 1]]></cell><cell>50.00</cell><cell>10.00</cell><cell>60.00</cell><cell><![CDATA[]]></cell></row><row id='5'><cell>5</cell><cell>2007-10-05</cell><cell><![CDATA[Client 3]]></cell><cell>100.00</cell><cell>0.00</cell><cell>100.00</cell><cell><![CDATA[no tax at all]]></cell></row><row id='4'><cell>4</cell><cell>2007-10-04</cell><cell><![CDATA[Client 3]]></cell><cell>150.00</cell><cell>0.00</cell><cell>150.00</cell><cell><![CDATA[no tax]]></cell></row></rows>
解决方案六:
直接拿你贴出来的数据在4.4.0版本的jqGrid下没有问题。自己f12看下浏览器实际得到的数据是什么,怕是和你控制台输出的不一样
解决方案七:
你返回的是xml 格式的数据,xml的数据我没试过,以前都是用的json 你的 3 是3条,说明这个已经读取到了。
http://www.trirand.com/blog/jqgrid/jqgrid.html 你看看 php返回的结构rows--->page--->total---->records---->cell ,每一个单元格是cell 的。不是你 这种形式,所以你可以写尝试后台自己做个假的数据和 官方的那种格式的xml 看看。jqgrid 源码我没看不知道他循环迭代数据是怎么个表现形式。
echo ""<?xml version='1.0' encoding='utf-8'?$etn"";echo ""<rows>"";echo ""<page>"".$page.""</page>"";echo ""<total>"".$total_pages.""</total>"";echo ""<records>"".$count.""</records>"";// be sure to put text data in CDATAwhile($row = mysql_fetch_array($resultMYSQL_ASSOC)) { echo ""<row id='"". $row[id].""'>""; echo ""<cell>"". $row[id].""</cell>""; echo ""<cell>"". $row[invdate].""</cell>""; echo ""<cell><![CDATA["". $row[name].""]]></cell>""; echo ""<cell>"". $row[amount].""</cell>""; echo ""<cell>"". $row[tax].""</cell>""; echo ""<cell>"". $row[total].""</cell>""; echo ""<cell><![CDATA["". $row[note].""]]></cell>""; echo ""</row>"";}echo ""</rows>"";
解决方案八:
对了 无聊码农 说的是4.4 , 我看的这个是4.0 http://www.trirand.com/blog/jqgrid/jqgrid.html
解决方案九:
包我导入了,不知道为什么还报:Uncaught TypeError: Cannot read property 'integer' of undefined这个错误?数据出不来,不知道是不是这个错误导致的!
解决方案十:
可能是包的兼容性的问题