2016-02-09 61 views
0

在以下的demo中,我需要關於每個分組數據的meta-info在頂部。因此,讓我們說如果我想要sum,那麼單個列的每行的總和(只有可加數量)必須出現在頂部的分組列。 grouped sum for tax of one columnjqgrid分組中的其他信息

以下是完整的代碼。

$(function() { 
    "use strict"; 
    $("#grid1").jqGrid({ 
     colModel: [ 
      { name: "name", label: "Client", width: 53 }, 
      { name: "invdate", label: "Date", width: 75, align: "center", sorttype: "date", 
      formatter: "date", formatoptions: { newformat: "d-M-Y" } }, 
      { name: "tax", label: "Tax", width: 41, template: "number" }, 
      { name: "closed", label: "Closed", width: 59, template: "booleanCheckboxFa", firstsortorder: "desc" }, 
      { name: "ship_via", label: "Shipped via", width: 87, align: "center", formatter: "select", 
      formatoptions: { value: "FE:FedEx;TN:TNT;DH:DHL", defaultValue: "DH" } } 
     ], 
     data: [ 
      { id: "10", invdate: "2015-10-01", name: "test", amount: "" }, 
      { id: "20", invdate: "2015-09-01", name: "test1", tax: "29.00", closed: false, ship_via: "FE" }, 
      { id: "30", invdate: "2015-09-01", name: "test1", tax: "32.00", closed: false, ship_via: "FE" }, 
      { id: "40", invdate: "2015-10-04", name: "test4", tax: "10.00", closed: true, ship_via: "TN" }, 
      { id: "50", invdate: "2015-10-31", name: "test1", tax: "20.00", closed: false, ship_via: "FE" }, 
      { id: "60", invdate: "2015-09-06", name: "test4", tax: "30.00", closed: false, ship_via: "FE" }, 
      { id: "70", invdate: "2015-10-04", name: "test4", tax: "10.00", closed: true, ship_via: "TN" }, 
      { id: "80", invdate: "2015-10-03", name: "test8", tax: "20.00", closed: false, ship_via: "FE" }, 
      { id: "90", invdate: "2015-09-01", name: "test3", tax: "30.00", closed: false, ship_via: "TN" }, 
      { id: "100", invdate: "2015-09-08", name: "test1", tax: "30.00", closed: true, ship_via: "TN" }, 
      { id: "110", invdate: "2015-09-08", name: "test11", tax: "30.00", closed: false, ship_via: "FE" }, 
      { id: "120", invdate: "2015-09-10", name: "test12", tax: "30.00", closed: false, ship_via: "FE" } 
     ], 
     iconSet: "fontAwesome", 
     rownumbers: true, 
     pager: true, 
     rowNum: 10, 
     sortname: "invdate", 
     sortorder: "desc", 
     caption: "The grid, which uses predefined formatters and templates" 
    }); 
    $("#grid1").jqGrid('groupingGroupBy','name'); 
}); 
+0

你笑結果如果你想獲得有關你的新問題的答案,uld開始[[接受]](http://meta.stackexchange.com/a/5235/147495)回答你以前的問題。由於搜索引擎使用接受狀態和投票計數,所以其他用戶幾乎不會找到不被接受的投票答案。 – Oleg

+0

@奧列格我已經upvoted的答案,但他們只會反映當我有至少15的聲譽。 –

+0

有**兩種不同的事情**:接受和投票。你留意有15個聲望點進行投票,但是每個用戶都有權*並且他應該*接受他的問題的答案。我在之前的評論中發佈了鏈接http://meta.stackexchange.com/a/5235/147495,其中顯示了您應該點擊的內容。因此,你可以考慮你的舊問題的答案,並接受答案。順便也會增加你的聲望。 – Oleg

回答

1

實現這個需求,最簡單的方法是groupingViewgroupSummaryPos: ["header"]財產的使用情況,以確定summaryType: "sum"和可選summaryTpl在列,其中要顯示摘要信息(在你的案件列amount

看到修改後的演示https://jsfiddle.net/OlegKi/stn2yfxn/9/它顯示象下面

enter image description here

+0

即使數據按金額分組,如何顯示稅額和總額的總和? –

+0

@johndoe:您只需在要查看組中總數的列(您的案例中爲「tax」和「total」)中定義'summaryType:'sum''。 – Oleg