2017-07-19 56 views
0

我有一個jqgrid的圖像如下所示,我想獲得'數量Varience'列的總和,但列值在文本框!你能幫我做到這一點?我想把這筆錢變成一個文本框!如何獲得jqgrid中的文本框的列的總和

enter image description here

function grid() { 
     debugger 
     var subid = $("#cmbProduct").val(); 
     $('#griddata').html('<table class="table" id="jqgrid"></table>') 
     $('#jqgrid').jqGrid({ 
      url: '/Inventor/GetAllProductsAvailableStocktoStockAdjustmentGrid?SUBID=' + subid, 
      datatype: 'json', 
      mtype: 'GET', 
      //columns names 
      colNames: ['ProductId', 'Sub Category', 'Product Code', 'Product Name', 'Available Stock', 'New Stock', 'Qty Varience', 'Stock Loss/Profit','LastUnitPrice1','LastUnitPrice2' ,'LastQty1','LastQty2' , 'Update', /*'Cancel',*/], 
      //columns model 
      colModel: [ 
      { name: 'ProductId', index: 'ProductId', hidden: true }, 
      { name: 'SubCategoryName', index: 'SubCategoryName', align: 'left', width: 250, sortable: false }, 
      { name: 'Product_ProductCode', index: 'Product_ProductCode', align: 'left', width: 120, sortable: false }, 
      { name: 'ProductName', index: 'ProductName', align: 'left', width: 230, sortable: false }, 
      { name: 'AvaiStock', index: 'AvaiStock', align: 'left', width: 80, sortable: false }, 
      { name: 'New_Stock', index: 'New_Stock', align: 'left', width: 70, sortable: false }, 
      { name: 'Qty_Varience', index: 'Qty_Varience', align: 'left', width: 80, sortable: false }, 
      { name: 'Stock_LossorProfit', index: 'Stock_LossorProfit', align: 'left', width: 90, sortable: false }, 

      { name: 'Update', index: 'Update', align: 'center', width: 90, sortable: false } 
      ], 
      pager: '#jqgrid', 
      rowNum: 10, 
      sortname: 'ProductName', 
      sortorder: "desc", 
      viewrecords: true, 
      width: 'auto', 
      height: 'auto', 
      gridview: true, 
      rowNum: 2000, 
      rowTotal: 200, 
      rowList: [20, 30, 50, 100], 
      rownumbers: false, 
      rownumWidth: 40, 
      loadonce: true, 
      // footerrow: true, 
      afterSaveCell: function (rowid, cellname, value, iRow, iCol) { 
      }, 
      subGrid: false, 
      gridComplete: function() { 
       var ids = jQuery("#jqgrid").jqGrid('getDataIDs'); 
       for (var i = 0; i < ids.length; i++) { 
        var cl = jQuery("#jqgrid").getRowData(i + 1).ProductId; 
        var cl1 = jQuery("#jqgrid").getRowData(i + 1).AvaiStock; 
        var cl2 = jQuery("#jqgrid").getRowData(i + 1).New_Stock; 
        var cl3 = jQuery("#jqgrid").getRowData(i + 1).Qty_Varience; 
        var cl4 = jQuery("#jqgrid").getRowData(i + 1).Stock_LossorProfit; 

        Ed = '<input style="height:25px;" type="button" value="UPDATE" class="btn btn-success " onclick="UpdatesingleProductPrice(\'' + cl + '\')"/> ' 
        Avs = '<input style="height:25px;" type="text" class="input-Avs form-control col-md-3 center-block input-sm" id="input-Avs-' + cl + '" value="' + cl1 + '" disabled /> ' 
        Nw = '<input style="height:25px;" type="text" class="input-Nw form-control col-md-3 center-block input-sm" id="input-Nw-' + cl + '" onkeyup =calstockadj("' + cl + '") value="0" /> ' 
        Qv = '<input style="height:25px;" type="text" class="input-Qv form-control col-md-3 center-block input-sm" id="input-Qv-' + cl + '" value="' + cl3 + '" disabled/> ' 
        Sl = '<input style="height:25px;" type="text" class="input-Sl form-control col-md-3 center-block input-sm" id="input-Sl-' + cl + '" value="' + cl4 + '" disabled /> ' 

        jQuery("#jqgrid").jqGrid('setRowData', ids[i], { Update: Ed }); 
        jQuery("#jqgrid").jqGrid('setRowData', ids[i], { AvaiStock: Avs }); 
        jQuery("#jqgrid").jqGrid('setRowData', ids[i], { New_Stock: Nw }); 
        jQuery("#jqgrid").jqGrid('setRowData', ids[i], { Qty_Varience: Qv }); 
        jQuery("#jqgrid").jqGrid('setRowData', ids[i], { Stock_LossorProfit: Sl });     


       } 
      }, 
     }); 
    } 
+0

最後我得到了答案! – user7702234

回答

0

函數計算(E){

 var sum123 = 0; 
      $('#input-Qv-' + e + '').each(function() { 
       sum123 += +$(this).val(); 
      }); 
     } 
0

你可以得到總這樣的:

 function ShowToal() { 
     var sum = 0; 
     $('#griddata').find('td[aria-describedby="grid-table_Qty_Varience"]').each(function() { 
      sum += $(this).html(); 
     }); 
    }