Identifying visible columns for custom export

QuestionsIdentifying visible columns for custom export
Richard Samson asked 5 years 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 5 years 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
Grid 4 PHP Framework
 
Richard Samson answered 5 years 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 years 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 =

Login with your Social Id:

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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?