0

メイングリッドデータをjson(mysqlから)経由でロードします。

私のグリッドは注文で構成されています。各注文には、いくつかのアイテム(注文明細)が含まれています。

ロード時に1つのクエリですべての注文明細をクエリしたいと思います。これらの注文明細は、注文IDでグループ化する必要があります。

これが私が欲しいものです:メイングリッド:IDごとに1つの行のみを表示します(サブ行の値の合計を含む)サブグリッド:各メイン行に「+」。クリックすると、サブグリッドが表示され、各サブ行が表示されます

これはjqGridで可能ですか?または、サブグリッドに対して追加のクエリを実行する必要ありますか?

よろしくオレ

4

2 に答える 2

0
<script type="text/javascript">
jQuery(document).ready(function(){ 
jQuery("#list").jqGrid({
url:'example.php',
datatype: 'xml',
mtype: 'GET',
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[ 
  {name:'invid', index:'invid', width:55}, 
  {name:'invdate', index:'invdate', width:90}, 
  {name:'amount', index:'amount', width:80, align:'right'}, 
  {name:'tax', index:'tax', width:80, align:'right'}, 
  {name:'total', index:'total', width:80, align:'right'}, 
  {name:'note', index:'note', width:150, sortable:false} 
],
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'invid',
sortorder: 'desc',
viewrecords: true,
caption: 'My first grid',
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
// we pass two parameters
// subgrid_id is a id of the div tag created within a table
// the row_id is the id of the row
// If we want to pass additional parameters to the url we can use
// the method getRowData(row_id) - which returns associative array in type name-value
// here we can easy construct the following
   var subgrid_table_id;
   subgrid_table_id = subgrid_id+"_t";
   jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
   jQuery("#"+subgrid_table_id).jqGrid({
      url:"subgrid.php?q=2&id="+row_id,
      datatype: "xml",
      colNames: ['No','Item','Qty','Unit','Total'],
      colModel: [
        {name:"num",index:"num",width:80,key:true},
        {name:"item",index:"item",width:130},
        {name:"qty",index:"qty",width:80,align:"right"},
        {name:"unit",index:"unit",width:80,align:"right"},           
        {name:"total",index:"total",width:100,align:"right",sortable:false}
      ],
      height: '100%',
      rowNum:20,
      sortname: 'num',
      sortorder: "asc"
   });
    }
  }); 
}); 
</script>

参照:http ://www.trirand.com/jqgridwiki/doku.php?id = wiki:subgrid_as_grid

于 2013-03-14T12:43:04.163 に答える
0

約100件の注文を表示する必要がある場合、特にChromeのような最新のWebブラウザとクイックJavaScriptを使用している場合は、すべてクライアント側で作業できます。サーバーは、IDでソートされたすべてのデータを提供する必要があります。を使用して、すべての日付を一度にロードできますloadonce: true

以前の回答(これ別の回答)のアイデアに基づいた回答を注意深く読むことをお勧めします。それはあなたの問題の解決策を提供すると思います。

于 2013-03-14T13:11:38.640 に答える