Author Topic: Saving data to a remote location using a custom script  (Read 2504 times)

atkingtornado

  • Newbie
  • *
  • Posts: 2
    • View Profile
Saving data to a remote location using a custom script
« on: January 23, 2015, 12:13:27 am »
I am trying to save data to a remote location using paramquery, I am reading the JSON file with a python script and then passing that data to paramquery. The location on the webserver where the code is located is not writable from the web, hence the need for a custom function. IS there a way to get the data from the grid and then send it back out to the remote location?

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Saving data to a remote location using a custom script
« Reply #1 on: January 23, 2015, 12:39:52 am »
The whole data of the grid i.e., dataModel.data (which is simply an array of row objects) can be sent to remote server with $.ajax POST.

atkingtornado

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Saving data to a remote location using a custom script
« Reply #2 on: January 26, 2015, 04:26:59 am »
Thank you for your reply!

When I try to print out dataModel.data to the console... for some reason It's not retrieving the data as it should. Here's my code:

$(document).ready(function(){
      
   var colM = [{ title: "DQPR", width: 100, dataType: "string", dataIndx: "dqpr" },
                  { title: "Status", width: 200, dataType: "string", dataIndx: "status" },
                  { title: "First Name", width: 200, dataType: "string", dataIndx: "firstName" },
                  { title: "Last Name", width: 200, dataType: "string", dataIndx: "lastName" }                                 
            ];
   

   var dataModel = {
       location: "remote",
      sorting: "local",
      paging: "local",
      dataType: "JSON",
      method: "GET",
      sortIndx: "dqpr",
      sortDir: "up",
      getUrl: function () {
         return{ url: "cgi-bin/get_json.py"}
      },
      getData: function (dataJSON) {
         var data = dataJSON.data;
         return { data: dataJSON.data };
      }
   };
   
   var newObj = {
      flexHeight: true,
      flexWidth: true,
      dataModel: dataModel,
      bottomVisible: true,
      colModel: colM,
      selectionModel: { mode: 'single' },
      editable: false,
      scrollModel: { horizontal: false },
      title: "DQPR Data",
      columnBorders: true
   };
   var $grid = $("#grid_json").pqGrid(newObj);
   console.log(JSON.stringify(dataModel.data));

});