ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: rgorantla on August 02, 2017, 12:15:57 am

Title: Couple of Questions
Post by: rgorantla on August 02, 2017, 12:15:57 am
1. Save State and load State from database:
    I am trying to save and load columns /Column Model to and from Database on to the Grid.Also, after re-ordering - would like to save it to database.
    Local storage is working fine but not database.

2. show/hide columns : when we select a column to hide or unhide can we push those to the end
Title: Re: Couple of Questions
Post by: paramvir on August 02, 2017, 04:46:29 pm
1. Please share a test case.

2. yes. colModel can be manipulated like an ordinary array and array methods i.e., splice/ push can be used to move the columns the way you need.

Just remember to call grid.refreshCM() and grid.refresh() after that.
Title: Re: Couple of Questions
Post by: rgorantla on August 08, 2017, 06:25:03 pm
Title: Re: Couple of Questions
Post by: paramvir on August 08, 2017, 10:31:19 pm
1. In case of database storage of state, it would remain same as https://paramquery.com/pro/demos/grid_state except the part where saveState and loadState is called.

Instead of simple grid.saveState()

Code: [Select]
var state = grid.saveState({save: false}); //returns state string.
//post state string to remote store via Ajax call $.ajax

Instead of simple grid.loadState()

Code: [Select]
//get state string from remote store via Ajax call $.ajax
and call grid.loadState({state: state}); in Ajax success callback.


2. Please share a test case of your implementation.
Title: Re: Couple of Questions
Post by: rgorantla on August 10, 2017, 08:31:23 pm
for the 1st one : Thank you, but i still have a an issue - i will send a sample

2. its the same as how it works in your demo. https://paramquery.com/pro/demos/showhide_columns . Instead of adding it in the order of the colmodel definition - can we show at the end. ?
Title: Re: Couple of Questions
Post by: paramvir on August 11, 2017, 02:50:36 pm
2. Yes as mentioned earlier colModel is a simple array, so it can be manipulated like one.

To move the items in an array,

a. remove items from their original location with splice().

b. place them at a new location ( in your case at the end ) with push().

and call grid.refreshCM() and grid.refresh() after that.
Title: Re: Couple of Questions
Post by: rgorantla on August 23, 2017, 01:50:41 am
hi,

2nd point got it to work . Thanks!

1st point :  I think i got it to work but state is having only few properties but not all properties. For ex : for Order Id i have class etc.. but all i see in the state is
{"colModel":[{"width":50,"dataIndx":"OrderID","filter":{}} ..Please let me know what else should i add to get this to include all properties - The reason i am asking is to get the complete colModel from database,
Title: Re: Couple of Questions
Post by: paramvir on August 23, 2017, 02:48:49 pm
state doesn't have the complete colModel, it's not meant for that.

if you need to serialize complete colModel, then use JSON.stringify ( complete colModel ) but please note that JSON.stringify discards any inline functions.