js查询access数据库后怎样转为jqGrid需要的格式

js查询access数据库后怎样转为jqGrid需要的格式,第1张

<html > <head>    <title>jqGrid 实例</title>

</head>

<body>

  <table id="list48"></table>

  <div id="plist48"></div>

</body>

  <script>

      $(function(){

pageInit();

});

function pageInit(){

var mydata = [

          {id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"1000",total:"211100"} ,

          {id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"2000",total:"32000"},

          {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",tax:"3000",total:"43000"},

          {id:"4",invdate:"2007-10-04",name:"test",note:"note",tax:"1000",total:"21000"},

          {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",tax:"2000",total:"32000"},

          {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",tax:"3000",total:"43000"},

          {id:"7",invdate:"2007-10-04",name:"test",note:"note",tax:"1000",total:"21000"}

        ];

      jQuery("#list48")jqGrid({

        data: mydata,

        datatype: "local",

        height: 'auto',

        rowNum: 30,

        rowList: [10,20,30],

           colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],

           colModel:[

             {name:'id',index:'id', width:60, sorttype:"int"},

             {name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"},

             {name:'name',index:'name', width:100, editable:true},

             {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true},

             {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true}, 

             {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, 

             {name:'note',index:'note', width:150, sortable:false} 

           ],

           pager: "#plist48",

           viewrecords: true,

           sortname: 'name',

           grouping:true,

             groupingView : {

               groupField : ['name'],               groupSummary : [true],//是否开启汇总页脚

               groupColumnShow : [true],//是否展示分组列

               groupText : ['<b>{0}</b>'],//组名的展示文字

               groupCollapse : false,

             },

           caption: "Grouping Array Data"

      });

}

  </script>

</html>

看下加粗的这段吧

function formatState(cellValue, options, rowObject) {

var rowId = optionsrowId;

var html = cellValue;

if (html != "0") {

html = '<label style="color: red;" >' + cellValue + '</label>';

}

else {

html = '<label>' + cellValue + '</label>';

}

return html;

}

这是获取列中的值。首先绑定需要查看data的列头,这样就可以看row data中过的值了。如果你想获取一行的数据,edit:true时,选中的行就可以获取到啊。不知道是不是你的答案,虽然会jqgrid,可是不知道你的问题究竟是啥

格式不对,应该输出这样才行

{"page":1,"total":2,"records":2,"rows":

[{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","白金卡"]}]

}

jqgrid的获取返回的数据源后是通过js把数据转换成了dom,通俗说就是<tr><td>内容1</td></tr>的html然后赋予到table对象的,让浏览器知道它是一个table的内容,浏览器就显示出来了。不导出数据想看数据源,IE的话可以使用fiddler监控>

以上就是关于js查询access数据库后怎样转为jqGrid需要的格式全部的内容,包括:js查询access数据库后怎样转为jqGrid需要的格式、怎样取得JQGrid中 row Data 的值 郁闷一个下午了, 先谢谢。。。、jqgrid 读取Json,json数据不显示(问题解决,追加100,感了....)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9417340.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存