Identifying visible columns for custom export

QuestionsIdentifying visible columns for custom export
Richard Samson asked 3 weeks ago

Hi Folks,

Is it possible to identify which columns are currently visible/selected via columns chooser toolbar icon for use within a customer CSV export function?

Many Thanks.

3 Answers
Abu Ghufran Staff answered 7 days ago

Hi,

You can check this variable: $_REQUEST[“jqgrid_colchooser_list1“]); in custom export callback. It contains comma separated column names. (here list1 is grid id you set in render function)

You can then refer demo code: http://phpgrid.org/demo/demos/export/export-custom.phps Line 149 and skip/add them in export.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Richard Samson answered 6 days ago

Thanks for the feedback.  If I output $_REQUEST from the callback it doesn’t appear to contain any column info:

$_REQUEST = Array ( [grid_id] => list1 [export] => 1 [jqgrid_page] => 1 [export_type] => [sidx] => 1 [sord] => asc [rows] => 20 [_search] => )

jqgrid_dist.php appears to merge the the $_REQUEST and $_COOKIE arrays before searching for fields to exclude, so if I look in our $_COOKIE arrays I can see the colchooser parameter.

$_COOKIE = Array ( [jqgrid_colchooser_list1] => department,deviceType,make,model, …

Unfortunately that cookie appears to be shared across pages and retains the last colchooser used, so if I then visit another phpgrid page on our site (or even reload the current page) that out of date column list would result in the export function trying to output those fields instead of what’s shown on screen!

Should my $_REQUEST definitely contain that value?  We’re running phpGrid v2.6.  Is there any other way to pull the active list of columns?  If not, could you please consider this feature for a future version?

Many Thanks.

Abu answered 5 days ago

You can use grid Id unique so that there is no list1 again in code. This way cookie will also be unique as it’s name contain grid id.

Your Answer

12 + 12 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!