ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on August 15, 2017, 01:20:01 pm

Title: Add Columns to columnSelector
Post by: queensgambit9 on August 15, 2017, 01:20:01 pm
I set some columns to columnSelector using this:

Code: [Select]
var newColumn = ['newColumn1', 'newColumn2'];
$("select.columnSelector").val(newColumn);

Works fine...but I would like to to append these columns to already existing columns in the columnSelector...what would be the best approach for this?
Title: Re: Add Columns to columnSelector
Post by: paramvir on August 15, 2017, 04:55:49 pm
Code: [Select]
var newColumn = ['newColumn1', 'newColumn2'];

var oldVal = $("select.columnSelector").val()

$("select.columnSelector").val(  oldVal.concat( newColumn ) )
Title: Re: Add Columns to columnSelector
Post by: queensgambit9 on August 15, 2017, 05:27:20 pm
Thanks, works fine.
When I make updates to the columnSelector, is it possible to run the function that controls the visibility of the column based on if the checkbox is selected on not?

Title: Re: Add Columns to columnSelector
Post by: paramvir on August 15, 2017, 10:16:09 pm
Now I'm not so clear on your question. Have you added the new columns to colModel or is it columnSelector alone?

BTW my previous code merely extends the selection of already existing options in a multiple select list, it doesn't add new options. I'm not sure how that works fine for you.

Please share the full context / objective of your use case and a jsfiddle if possible.
Title: Re: Add Columns to columnSelector
Post by: queensgambit9 on August 17, 2017, 12:36:15 pm
Sorry if a bit unclear.
I want the user to be able to choose layout from a dropdrown. It hides or show more columns and applies them on the initial setup.

http://jsfiddle.net/3rfy0xf9/4/
Title: Re: Add Columns to columnSelector
Post by: paramvir on August 17, 2017, 10:42:21 pm
Please check this: http://jsfiddle.net/3rfy0xf9/5/
Title: Re: Add Columns to columnSelector
Post by: queensgambit9 on August 18, 2017, 12:57:07 am
Thanks, works fine.
However, I would to take into consideration the initial state of hidden. If a column was hidden in initial state it still should be hidden after layout load.
Now all available columns seems to be used...

Title: Re: Add Columns to columnSelector
Post by: paramvir on August 18, 2017, 10:33:38 pm
The different ways you want to do it are business rules, which is outside the scope of support. http://jsfiddle.net/3rfy0xf9/6/

The grid related point to understand is:

To update values ( visible colums ) in columnSelector, please use:

Code: [Select]
$("select.columnSelector").val( cols ).pqSelect('refreshData');

where cols is an array of dataIndx of visible columns.