Author Topic: Issue related to "destroy" option and reusing the same grid.  (Read 6192 times)

Guoran

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
Issue related to "destroy" option and reusing the same grid.
« on: October 07, 2014, 06:14:36 pm »
In my code,  variable CM( colModel data) is passed to initialize the grid and CM is still in use in my code. After "destroy" option call, the CM which has new column data is passed to re-initalize the grid(the same DIV id). It is noticed that CM in the code is modified to previous value of CM although the grid properly shows in new colModel data. In fact, it is observed that the dataModel's data in some methods( for example getRowData) in paramQuery grid is using the previous data before calling "destroy" method by pqgrid("option","destroy").

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Issue related to "destroy" option and reusing the same grid.
« Reply #1 on: October 08, 2014, 11:23:49 pm »
your question is generalized and is related to the way the grid is initialized and how the different options are cloned before use by any jQueryUI widget.

The options are deep cloned and arrays are passed by rerefence as mentioned in this post:

http://api.jqueryui.com/jquery.widget/


We would be able to help you better if you post a specific example that shows how you have initialized the grid with colModel and data, how you made changes in the colModel and dataModel.data, how you reuse them in recreating the grid and what issue are you facing.
« Last Edit: October 08, 2014, 11:31:12 pm by paramquery »

karyn.ulriksen

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Issue related to "destroy" option and reusing the same grid.
« Reply #2 on: February 21, 2015, 02:16:13 am »
Is there a specific command you would recommend to identify if a pqGrid instance is initialized?  I'm having trouble finding a reliable jquery or pqGrid method to determine this.

karyn.ulriksen

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Issue related to "destroy" option and reusing the same grid.
« Reply #3 on: February 21, 2015, 02:40:50 am »
never mind, I found the following to work:   

if( pqtable.pqGrid( "instance" )) { pqtable.pqGrid( "destroy" ); }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Issue related to "destroy" option and reusing the same grid.
« Reply #4 on: February 21, 2015, 10:26:12 am »
To check whether an element has initialized pqGrid.

if $( ".selector" ).hasClass( 'pq-grid' )

and to get all pqGrid instances in a document.

var $pqgrids = $( ".pq-grid" );