Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
某些行上的Jquery数据表Colspan_Jquery_Json_Datatables - Fatal编程技术网

某些行上的Jquery数据表Colspan

某些行上的Jquery数据表Colspan,jquery,json,datatables,Jquery,Json,Datatables,好的,我有一个Jquery json调用。看起来有点像这样 $('#StockInvetoryReportList').dataTable({ "filter": false, "bLengthChange": false, "bPaginate": false, "bProcessing": true, "bServerSide": true, "sAjaxSource": "@Url.Actio

好的,我有一个Jquery json调用。看起来有点像这样

 $('#StockInvetoryReportList').dataTable({
        "filter": false,
        "bLengthChange": false,
        "bPaginate": false,
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "@Url.Action("GetStockInventoryBalance", "Reports")",
        "aoColumns": [{ "mData": "Date"},
      { "mData": "Name" },
    { "mData": "Quantity" },
    { "mData": "isSummary" }
    ],   
            "fnServerParams": function (aoData) {
                aoData.push({ "name" : "StockNo", "value": $('#MaterialName').val() }),
                { "name": "ReportDate", "value": $('#ReportDate').val() };
            }
    });
+------------+------+----------+------------+
|    Date    | Name | Quantity | Is Summary |
+------------+------+----------+------------+
| 10/01/2015 | Wire | 500      | False      |
+------------+------+----------+------------+
| 10/05/2015 | Wire | 500      | False      |
+------------+------+----------+------------+
| 10/15/2015 | Wire | 600      | False      |
+------------+------+----------+------------+
| 10/18/2015 | Wire | 100      | False      |
+------------+------+----------+------------+
| 10/19/2015 | Wire | 200      | False      |
+------------+------+----------+------------+
| October           | 1900     | True       |
+-------------------+----------+------------+
它生成这个表:

+------------+---------+----------+------------+
|    Date    | Name    | Quantity | Is Summary |
+------------+---------+----------+------------+
| 10/01/2015 | Wire    | 500      | False      |
+------------+---------+----------+------------+
| 10/05/2015 | Wire    | 500      | False      |
+------------+---------+----------+------------+
| 10/15/2015 | Wire    | 600      | False      |
+------------+---------+----------+------------+
| 10/18/2015 | Wire    | 100      | False      |
+------------+---------+----------+------------+
| 10/19/2015 | Wire    | 200      | False      |
+------------+---------+----------+------------+
| 10/31/2015 | October | 1900     | True       |
+------------+---------+----------+------------+
如果is summary为true,我想合并前两列。应该是这样的

 $('#StockInvetoryReportList').dataTable({
        "filter": false,
        "bLengthChange": false,
        "bPaginate": false,
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "@Url.Action("GetStockInventoryBalance", "Reports")",
        "aoColumns": [{ "mData": "Date"},
      { "mData": "Name" },
    { "mData": "Quantity" },
    { "mData": "isSummary" }
    ],   
            "fnServerParams": function (aoData) {
                aoData.push({ "name" : "StockNo", "value": $('#MaterialName').val() }),
                { "name": "ReportDate", "value": $('#ReportDate').val() };
            }
    });
+------------+------+----------+------------+
|    Date    | Name | Quantity | Is Summary |
+------------+------+----------+------------+
| 10/01/2015 | Wire | 500      | False      |
+------------+------+----------+------------+
| 10/05/2015 | Wire | 500      | False      |
+------------+------+----------+------------+
| 10/15/2015 | Wire | 600      | False      |
+------------+------+----------+------------+
| 10/18/2015 | Wire | 100      | False      |
+------------+------+----------+------------+
| 10/19/2015 | Wire | 200      | False      |
+------------+------+----------+------------+
| October           | 1900     | True       |
+-------------------+----------+------------+

当然,名单上还有更多的月份。我们将非常感谢您的帮助。我花了好几个小时来解决这个问题,终于解决了。我希望这会有所帮助

以下是您问题的答案:

var dgv_StockInvetoryReportList = $('#StockInvetoryReportList').dataTable({
        "filter": false,
        "bLengthChange": false,
        "bPaginate": false,
        "bProcessing": true,
        "bServerSide": true,
        "bSort": false,
        "sAjaxSource": "@Url.Action("GetStockInventoryBalance", "Reports")",
        "aoColumns": [{ "mData": "Date", "mRender": function (data, type, full) { return dtConvFromJSON(data); } },
        { "mData": "Name" },
        { "mData": "Quantity" },
            { "mData": "isSummary" },
        ],
        "fnServerParams": function (aoData) {
            aoData.push({ "name": "StockNo", "value": $('#MaterialName').val() });
            aoData.push({ "name": "ReportDate", "value": $('#ReportDate').val() });
        },

       //Here is the answer that I've created, 
       //All you have to do is to insert ID in every row that your datatable
       //created
      'fnCreatedRow': function (nRow, aData, iDataIndex) {   
           var cells = $('td', $(nRow));
           //I suggest you to make the word "TOTAL SUMMARY" instead of 
           //name of the month.. ^_^
           if ($(cells[1]).text().indexOf("//Insertthemonthhere") != -1) {
             $(nRow).attr('class', '//Name of the Class');
           }
       },
        //And here is where the cells span
       "drawCallback": function () {
             $("tbody").find("tr.total").each(function () {
                  var cells = $('td', this);
                  $(cells[1]).attr('colspan', 3); //adding span by 3
                  $(cells[2]).remove(); //remove the cell 
                  $(cells[0]).remove(); //remove the cell
             });

       }
});
我希望它能起作用-干杯^_^


--KKK

解决方案是否应使用datatable函数?或者它可能是任何东西。另外,一张表格也很好。我们在整个应用程序中都在使用datatable函数,并试图在所有页面中保持统一。请给出一个JSON的示例?JSON bro的示例是什么意思?请参阅json调用。结果的值在表中。@TheProvost,我是指JSON-我不想对其进行反向工程。我的意图是建议一个替代的解决方案-在dataTable body.Tnx中不能有真正的colspan!!!帮我省了一天的时间想清楚这一点:)但赏金还不能颁发。一有空我就给你奖励