ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: Guoran on October 07, 2014, 06:14:36 pm

Title: Issue related to "destroy" option and reusing the same grid.
Post by: Guoran 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").
Title: Re: Issue related to "destroy" option and reusing the same grid.
Post by: paramvir 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.
Title: Re: Issue related to "destroy" option and reusing the same grid.
Post by: karyn.ulriksen 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.
Title: Re: Issue related to "destroy" option and reusing the same grid.
Post by: karyn.ulriksen on February 21, 2015, 02:40:50 am
never mind, I found the following to work:   

if( pqtable.pqGrid( "instance" )) { pqtable.pqGrid( "destroy" ); }
Title: Re: Issue related to "destroy" option and reusing the same grid.
Post by: paramvir 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" );