Author Topic: Refreshing a Grid with multiple grids on the same page  (Read 344 times)

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 36
    • View Profile
Refreshing a Grid with multiple grids on the same page
« on: November 29, 2022, 04:15:27 am »
I have individual 3 grids, separated by tabs (UI Tabs) and I was trying to refresh them with updated source data (XML data).  I used the grid.refresh() method inside a SavedChanges() javaScript function, but it did not update the grid until I used the javascript window.location.reload() method.

Am I not using the grid.refresh() method correctly??  Below is my saveChanges function showing how I tried and failed to refresh my grids.

function saveChanges() {
      if (!$.active && !grid.getEditCell().$cell && grid.isDirty() && grid.isValidChange({ allowInvalid: true }).valid) {
       var gridChanges = grid.getChanges({ format: 'byVal' });
      //debugger
        $.ajax({
         url: '/STS/Content/files/code/gridEdits.cfc',      // for ColdFusion      

    data: {
               method: "realtimeEdit",
               list: JSON.stringify( gridChanges )
          },

           dataType: "json",
           type: "POST",
           async: true,
           beforeSend: function (jqXHR, settings) {
               grid.option("strLoading", "Saving..");
               grid.showLoading();
           },
           success: function (changes) {
               //commit the changes.     

               grid.commit({ type: 'add', rows: changes.addList });
               grid.commit({ type: 'update', rows: changes.updateList });
               grid.commit({ type: 'delete', rows: changes.deleteList });
           },
           complete: function () {
                 grid.hideLoading();
                grid.option("strLoading", $.paramquery.pqGrid.defaults.strLoading);
            
            grid.refresh();
            grid2.refresh();
            grid3.refresh();
            
            // This method below works, but the entire html page is reloaded
            //window.location.reload();
           }
       });
   }
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Refreshing a Grid with multiple grids on the same page
« Reply #1 on: November 29, 2022, 10:15:33 am »
I assume dataModel.location is "remote" in your case and you want to reload remote data. For that you can use refreshDataAndView() method.

Please read this topic: https://paramquery.com/pro/tutorial#topic-refreshView

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Refreshing a Grid with multiple grids on the same page
« Reply #2 on: November 29, 2022, 05:59:22 pm »
Yes, the data is remote.  Worked perfectly - thank you so very much!

-P