Author Topic: Sending data from Paramquery grid to controller in Spring mvc  (Read 4135 times)

bsolteam

  • Pro Deluxe
  • Full Member
  • *
  • Posts: 107
    • View Profile
I am facing one issue while sending the data to my controller.
The problem is i have one Paramquery grid and five textbox on screen. I am able to send data from grid alone but i have to send all grid data and textbox data at the same time as it is the requirement in my project. can someone suggest me how i can do that.

My code looks like :
$('body').on('click','#getreport',function(e)
         {
            var asofDate =$('#asofdate :selected').text();
            var startDate = $('#startdate').val();
            var endDate = $('#enddate').val();
            var reporttype = $('#reporttype').val();
            var format= $("input:radio[name=format]:checked").val();
            
                  var DM = $("#grid_json").pqGrid("option", "dataModel");
                  var griddata = DM.data;
                  alert('grid data...'+griddata);
                   
                 
                $.ajax({

                     dataType : "json",
                     contentType : "application/json; charset=utf-8",
                     type : "POST",
                     async : false,
                         url : "getVesselList",
                     data : JSON.stringify(griddata),
                     mimeType : 'application/json',
                     success : function() {
                        
                        alert("test...");
                        
                        
                     },
                     error : function(data, status, er) {
                        alert("error 565: " + " status: " + status + " er:" + er.message);

                     },
                     
                  });
                 
         });


With this code i am able to get grid data in my controller but i want other values asofdate,enddate,startdate,reporttype,format at the same time. Please suggest me how i can achieve this.


Thanks
   

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: Sending data from Paramquery grid to controller in Spring mvc
« Reply #1 on: July 08, 2014, 11:52:44 am »
Arrange all data in a single object

var obj = {griddata: griddata, fieldsData: { asofDate : asofDate , ... } }

data : JSON.stringify( obj ),

---------------------------
and make corresponding changes in java code to deserialize data from posted string.