1

I have question regarding adding another rowdata at the end of my jqgrid. What I wanted to do is that everytime I do a simple search on a particular transaction, and display it on my jqgrid, i want to have another row at the end which have my total computations. Below is my complete jqgrid code:.

$("#tblSupplier").jqGrid({
        url: '',
        datatype: 'local',
        jsonReader : {
            root: function(obj) {
                var root = [];               
                if  ('error' in obj) 
                {
                    showMessage(obj.error['class'] + ' error: ' + obj['error']['msg']);
                }
                else
                {
                    var totalBdFt = '';
          var bdft=0;
          var amt=0;
          var totalAmount = '';
          $.each(obj['result']['main']['rowdata'], function(rowIndex, rowDataValue) {
                    var row = {};

            $.each(rowDataValue, function(columnIndex, rowArrayValue) {
              var fldName = obj['result']['main']['metadata']['fields'][columnIndex].name;  
              row[fldName] = rowArrayValue;
              if (fldName == 'transaction_date'){
                $('#tallyDate').val(rowArrayValue);
              }                
              if (fldName == 'supplier_name'){   
                $('#supplierName').val(rowArrayValue); 
              }                
              if (fldName == 'board_foot'){ 
                bdft = parseFloat(bdft) + parseFloat(rowArrayValue);
              }                
              if (fldName == 'total_amount'){   
                amt = parseFloat(amt) + parseFloat(rowArrayValue); 
              }                
            });           
            root[rowIndex] = row; 
            $('#totalBdft').val(parseFloat(bdft));
            $('#totalAmt').val(parseFloat(amt));
                    });
                };
                return root;
            },          
            page: "result.main.page",           
            total: "result.main.pageCount",
            records: "result.main.rows",
            repeatitems: false,
            id: "0"
        },
    serializeGridData: function(postData) {

      var jsonParams = {
      'SessionID':  $.cookie("SessionID"),
      'dataType': 'data',
      'simple_search_value':trim($("#searchSupAny").val()),
      'recordLimit': postData.rows,
      'recordOffset': postData.rows * (postData.page - 1),
      'rowDataAsObjects': false,
      'queryRowCount': true,
      'sort_fields': postData.sidx
      };              

      return 'json=' + JSON.stringify(jsonParams);
    },
    loadError: function(xhr, msg, e) { 
      showMessage('HTTP error: ' + JSON.stringify(msg) + '.');
    },
        colNames:['Transaction Num', 'Wood Classification', 'Specie', 'Total Board Foot', 'Price', 'Total Amount'], 
        colModel:[
            {name:'transaction_num'},
      {name:'wood_classification_desc'},
      {name:'wood_specie_desc'},
      {name:'board_foot'},
      {name:'price'},
      {name:'total_amount'}
        ],                              
        viewrecords: true,              
        sortname: 'transaction_num',
        sortorder: 'desc',
        loadonce:false,     
    height:'100%',
    caption: "sample summary"
    });
  var newRowData = [{ "wood_classification_desc": 'total should b here', "wood_specie-desc": "total bdft here", "total_amount": "total amount here"}];
  $("#tblSupplier").addRowData('transaction_num',newRowData); 
 })

my newRowData displays only on load, but after I do a simple search, it will also gone. But my jqgrid with ajax data working good. So how should I do it to maintain my additional row everytime I call ajax?

jayAnn
  • 827
  • 3
  • 18
  • 38
  • as usual in jqGrid, Oleg has [the answer][1]. [1]: http://stackoverflow.com/questions/2820254/jqgrid-loading-data-into-the-footer-row/2820563#2820563 – J. Ed Jul 26 '11 at 10:50
  • 1
    @sJhonny: First of all thanks for the reference to my old answer. Small advice: to write the link in the comment you can use the following syntax: `[the answer](http://stackoverflow.com/questions/2820254/jqgrid-loading-data-into-the-footer-row/2820563#2820563)`. The results will look as [the answer](http://stackoverflow.com/questions/2820254/jqgrid-loading-data-into-the-footer-row/2820563#2820563). – Oleg Jul 26 '11 at 13:05

0 Answers0