2017-07-19 1 views
0

Ich habe eine jqgrid das Bild wie unten gezeigt und ich möchte die Summe der 'Qty Varience' Spalte, aber Spalte Werte sind in Textbox! Können Sie mir helfen, dies zu tun ? Ich möchte die Summe in eine Textbox bekommen!Wie bekomme ich die Summe der Spalte mit Textbox in 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

Schließlich bekam ich die Antwort! – user7702234

Antwort

0

Funktion berechnen (e) {

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

Sie können insgesamt wie folgt erhalten:

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