Author Topic: reload local data array  (Read 4136 times)

elearnster

  • Pro Economy
  • Newbie
  • *
  • Posts: 20
    • View Profile
reload local data array
« on: September 18, 2014, 04:26:37 am »
When I create a dynamic web page, I have 8 data arrays that are predefined and default to the first array.  Outside of the PG Grid's $(function () call, I need to re-assign a global variable are reload a different data array.  I tried to destroy the Grid but unable to reload the table.  Can you suggest a strategy to accomplish this?  Thank you in advance.  eLearnster

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6311
    • View Profile
Re: reload local data array
« Reply #1 on: September 18, 2014, 01:37:10 pm »
$grid can be referenced by $( '.selector' ) outside of the $(function ()) call

different array can be assigned to grid by changing dataModel.data and calling refreshView after that.

elearnster

  • Pro Economy
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: reload local data array
« Reply #2 on: September 18, 2014, 11:18:08 pm »
The approach to change the data modal array makes sense.  I initially use arrayData1 and then try to change it to arraryData2.

Here is my syntax inside of the PQ-Grid:

        //** Execute the best year worksheet.
        var $grid1 = $("#grid_Compute_Stats").pqGrid(obj_Grid1);

Here is my syntax outside of the PQ-Grid:

        $Grid1.pqGrid("option", "dataModel", { data: arrayData1 });
        $grid1.pqGrid("refreshDataAndView");
       
        However, I am having an "Uncaught reference error: $Grid1 is not defined."

Your help is appreciated. 
eLearnster.



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6311
    • View Profile
Re: reload local data array
« Reply #3 on: September 18, 2014, 11:28:50 pm »
The reference should be re obtained outside of the $(function(){})

var $grid1 = $("#grid_Compute_Stats");
$grid1.pqGrid("option", "dataModel", { data: arrayData2 });
$grid1.pqGrid("refreshDataAndView");

elearnster

  • Pro Economy
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: reload local data array
« Reply #4 on: September 20, 2014, 10:59:18 pm »
Your approach worked great.  I have been using PQ-Grid for a couple of months and the software and support has been outstanding.
eLearnster.