Author Topic: Attach existing grid object to a div  (Read 1649 times)

mgolowczynski

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 1
    • View Profile
Attach existing grid object to a div
« on: December 05, 2017, 02:53:25 pm »
I’m creating a grid in a div (using the constructor in the normal way), and I’m adding the grid object that the constructor returns to a container object, as my page contains a number of grids and I want to have easy access to all the grid objects, as follows:
 
var myGrid = pq.grid("#gridDivName”, obj);
gridContainerObject[gridId] = myGrid;
 
The div that I am creating the grid in is in a dialog (as per the grid in dialog example on the demos webpage).  When the dialog is closed I would like to keep the grid in memory so that I can show it in the dialog again later, therefore I am not destroying the grid when the dialog is closed (and not removing it from my container object).  How do I reattach the grid (using the grid object that I’ve stored in my container object) to the div again when I show the dialog again (i.e. I can’t use the same constructor again as I’m not creating a brand new grid)?

Thank you for your help.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Attach existing grid object to a div
« Reply #1 on: December 05, 2017, 03:10:27 pm »
Assuming that you are neither destroying nor detaching the grid from popup while close.

In the open event of popup, refresh the grid if already initialized else initialize the grid.

Code: [Select]
open: function (evt, ui) {   
if($("#grid_popup").pqGrid('instance'))
$("#grid_popup").pqGrid('refresh');
else   
$("#grid_popup").pqGrid(obj);
},
close: function () {
//$("#grid_popup").pqGrid('destroy');
},
« Last Edit: December 05, 2017, 03:12:38 pm by paramquery »