Export not working

Talk about Printing & Exporting Settings

Moderators: ne_moj, zewa

HLEBOEUF
Senior
Senior
Posts: 27
Joined: Jan 21st, '10, 17:17

Export not working

Postby HLEBOEUF » Oct 10th, '10, 07:28

Hello,

I'm having this code in my data-grid-php

Code: Select all

         $printing_option = true;
         $dgrid->AllowPrinting($printing_option);
         ##  *** set exporting option: true(default) or false
         $exporting_option = true;
            $exporting_directory = "export/";               
            $export_all = true;
            $dgrid->AllowExporting($exporting_option, $exporting_directory, $export_all);

         $exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"false");
            $dgrid->AllowExportingTypes($exporting_types);


In the download.php i've changed this code a bit

Code: Select all

<?php
    // Last changed: 09.09.2010


    session_start();   

    $dir  = (isset($_SESSION['datagrid_export_dir']) && $_SESSION['datagrid_export_dir'] != null) ? $_SESSION['datagrid_export_dir'] : "";
    $file = (isset($_SESSION['datagrid_export_file']) && $_SESSION['datagrid_export_file'] != null) ? $_SESSION['datagrid_export_file'] : "";
    $debug = (isset($_SESSION['datagrid_debug']) && $_SESSION['datagrid_debug'] != null) ? $_SESSION['datagrid_debug'] : "";

echo "[dir][" . $dir ."]<hr>";
echo "[file][" . $file ."]<hr>";
echo "[debug][" . $debug ."]<hr>";



The strage thing is that all these variables are empty ....

Any idea what this could be ?

I'm running te grid in a Joomla site, but all other features are working fine.

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: Export not working

Postby administrator » Oct 10th, '10, 07:33

You have to define session_start(); in your main php file too, because these variables are session variables.

HLEBOEUF
Senior
Senior
Posts: 27
Joined: Jan 21st, '10, 17:17

Re: Export not working

Postby HLEBOEUF » Oct 10th, '10, 17:32

Code is in, but maybe at the wrong place ???

Code: Select all

<?php

 session_start();

   $thismodule = 6;
   $my = & JFactory::getUser();
   $db = JFactory::getDBO();
   $myid = $my->id;

   if ($myid > 0)
   {
      $db->setQuery("SELECT secu_id FROM `dwe_sec_user` WHERE `secm_id`=".$thismodule." AND `jusr_id`=".$myid." LIMIT 1");
      $result = $db->loadResult();
      if ($result > 0)
      {
         header("content-type: text/html; charset=utf-8");

         define ("DATAGRID_DIR", "../datagrid/");
         define ("PEAR_DIR", "../datagrid/pear/");

         require_once(DATAGRID_DIR.'datagrid.class.php');
         require_once(PEAR_DIR.'PEAR.php');
         require_once(PEAR_DIR.'DB.php');

         $DB_USER='...';
         $DB_PASS='...';
         $DB_HOST='...';
         $DB_NAME='...';

         ob_start();
         $db_conn = DB::factory('mysql');
         $result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
         if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }

         $sql =   "select ....;";

         ##  *** set needed options and create a new class instance
         $debug_mode = false;
         $messaging = true;
         $unique_prefix = "svlst_";
         $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);

         /* ?option=com_jumi&fileid=3&Itemid=57 */
         $http_get_vars = array("option", "fileid", "Itemid");
         $dgrid->SetHttpGetVars($http_get_vars);

         ##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
         $dg_encoding = "utf8";
         $dg_collation = "utf8_unicode_ci";
         $dgrid->SetEncoding($dg_encoding, $dg_collation);

         ##  *** set data source with needed options
         $default_order_field = "datesubmitted";
         $default_order_type = "ASC";
         $dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);


         ## +---------------------------------------------------------------------------+
         ## | 2. General Settings:                                                      |
         ## +---------------------------------------------------------------------------+
         ##  *** allow multirow operations
         $multirow_option = false;

            ##  *** set layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized
            $layouts = array("view"=>"0", "edit"=>"0", "details"=>"1", "filter"=>"1");
            $dgrid->setLayouts($layouts);

            ##  *** set modes for operations ("type" => "link|button|image")
            ##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
            $modes = array(
                           "add"     =>array("view"=>false, "edit"=>false, "type"=>"link"),
                           "edit"     =>array("view"=>false, "edit"=>false,  "type"=>"link", "byFieldValue"=>""),
                           "cancel"  =>array("view"=>false, "edit"=>false,  "type"=>"link"),
                           "details" =>array("view"=>false, "edit"=>false, "type"=>"link"),
                           "delete"  =>array("view"=>false, "edit"=>false,  "type"=>"image")
                          );
            $dgrid->setModes($modes);

         ##  *** set CSS class for datagrid
         ##  *** "default|blue|gray|green|pink|empty|x-blue|x-gray|x-green" or your own css style
         $css_class = "x-blue";
         $dgrid->SetCssClass($css_class);

         ##  *** "default" or "blue" or "gray" or "green" or "pink" or your own css file
         ##  *** set DataGrid caption
         $dg_caption = "Lijst Inschrijvingen";
         $dgrid->SetCaption($dg_caption);

         ## +---------------------------------------------------------------------------+
         ## | 3. Printing & Exporting Settings:                                         |
         ## +---------------------------------------------------------------------------+
         ##  *** set printing option: true(default) or false
         $printing_option = true;
         $dgrid->AllowPrinting($printing_option);
         ##  *** set exporting option: true(default) or false
         $exporting_option = true;
            $exporting_directory = "export/";               
            $export_all = true;
            $dgrid->AllowExporting($exporting_option, $exporting_directory, $export_all);

         $exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"false");
            $dgrid->AllowExportingTypes($exporting_types);

         ## +---------------------------------------------------------------------------+
         ## | 4. Sorting & Paging Settings:                                             |
         ## +---------------------------------------------------------------------------+
         ##  *** set paging option: true(default) or false
         $paging_option = true;
         $rows_numeration = false;
         $numeration_sign = "N #";
         $dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
         ##  *** set paging settings
         $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
         $top_paging = array();
         $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
         $default_page_size = 100;
         $dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);


         ## +---------------------------------------------------------------------------+
         ## | 6. View Mode Settings:                                                    |
         ## +---------------------------------------------------------------------------+
         ##  *** set view mode table properties
         $vm_table_properties = array("width"=>"95%");
         $dgrid->SetViewModeTableProperties($vm_table_properties);
         ##  *** set columns in view mode
         ##  *** Ex.: "on_js_event"=>"onclick='alert("Yes!!!");'"
         ##  ***      "barchart" : number format in SELECT SQL must be equal with number format in max_value
         $vm_colimns = array(
            "Persoon"    => array("header"=>"Persoon", "type"=>"label", "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Email"      => array("header"=>"Email",   "type"=>"label", "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "ResNbr"     => array("header"=>"Res N°",  "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "ResDatum"   => array("header"=>"Res Dat", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "TeBetalen"  => array("header"=>"Te Betalen", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu1"      => array("header"=>"x Menu 1", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu2"      => array("header"=>"x Menu 2", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu3"      => array("header"=>"x Menu 3", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu4"      => array("header"=>"x Menu 4", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu5"      => array("header"=>"x Menu 5", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Menu6"      => array("header"=>"x Menu 6", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            "Opmerking"  => array("header"=>"Opmerking", "type"=>"label", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"true", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
            );
         $dgrid->SetColumnsInViewMode($vm_colimns);



         ## +---------------------------------------------------------------------------+
         ## | 8. Bind the DataGrid:                                                     |
         ## +---------------------------------------------------------------------------+
         ##  *** bind the DataGrid and draw it on the screen
         $dgrid->Bind();
         ob_end_flush();

      }
      else
      {
         echo "Sorry, U heeft niet de nodige rechten om deze menukeuze te activeren.<br>";
         echo "Indien U denkt dat er iets fout is, mail naar site@dewildeeend.be";
      }
   }

function my_format_date($last_login_time)
{
    $last_login = @mktime(substr($last_login_time, 11, 2), substr($last_login_time, 14, 2),
                        substr($last_login_time, 17, 2), substr($last_login_time, 5, 2),
                        substr($last_login_time, 8, 2), substr($last_login_time, 0, 4));
    if($last_login_time != ""){
        return @date("M d, Y g:i A", $last_login);
      }
      else return "";
}
?>

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: Export not working

Postby administrator » Oct 11th, '10, 12:05

You have ExportDownloadFile() method in datagrid.class.php with

$_SESSION['datagrid_export_dir']= $this->exportingDirectory;
$_SESSION['datagrid_export_file']= $file_name;
$_SESSION['datagrid_debug']= $this->debug;

Please debug it to see what happens.

elinet
Newbie
Newbie
Posts: 1
Joined: Jan 5th, '11, 03:53

Re: Export not working

Postby elinet » Jan 5th, '11, 03:56

I've the same problem.
In ExportDownloadFile() method $_SESSION variables are ok but when I tried to var_dump($_SESSION); in scripts/download.php $_SESSION is empty.
I've session_start(); in main php file.

If you could show online demo with code that's working.

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: Export not working

Postby administrator » Jan 8th, '11, 15:27

You have to use session_start(); both in your main file and download.php file too.

Mister
Senior
Senior
Posts: 33
Joined: Dec 8th, '10, 10:05
Location: Ukraine(eastern part of Europe :D ), Kharkiv
Contact:

Re: Export not working

Postby Mister » Feb 8th, '11, 10:32

to load datagrid file I use jQuery function load(). Everithing is good until I did not click to export file.
session_start();
Only new window opens and current page load in it, what does it mean?

I tried to debug and has found out that when trying to export - download.php is inaccessible. Why so? It is loading some page but not download.php!

I found out that variable $req_export = $this->GetVariable('export'); in protected function ExportTo() is false, that is why it is not exporting. Where and when it is initialize?
Here is the code, I insert it in main code like this

Code: Select all

$.ajax({
                           type: "POST",
                           url: "movement_reports.php",
                           data: "",
                           success: function(data){
                                $("#show_movement_reports").append(data);
                               
                           }
                         });

movement_reports.php

Code: Select all

<?php
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling:                                                    |
## +---------------------------------------------------------------------------+
##  *** define a relative (virtual) path to datagrid.class.php file
##  *** (relatively to the current file)
##  *** RELATIVE PATH ONLY ***
    session_start();
   
   
   
    define ("DATAGRID_DIR", "datagrid/");                     /* Ex.: "datagrid/" */
    define ("PEAR_DIR", "datagrid/pear/");                    /* Ex.: "datagrid/pear/" */
//  http://localhost/pages/datagrid/styles/default/images/excel_r.gif
//  http://localhost/datagrid/styles/default/images/search_unhide_r.gif
    require_once(DATAGRID_DIR.'datagrid.class.php');
    require_once(PEAR_DIR.'PEAR.php');
    require_once(PEAR_DIR.'DB.php');
 
##  *** creating variables that we need for database connection
    require_once ('settings.php');
   
   
   
    ob_start();
   
   
   
    header('Content-Type: text/html; charset=utf-8');
    echo chr(239).chr(187).chr(191);
   
    /*$time_from = $_GET['time_from'];
    $time_to = $_GET['time_to'];
    $car_imei = $_GET['imei']; */
    $time_from = '2011-02-03 08:00:00';
    $time_to = '2011-02-03 10:00:00';
    $car_imei = '11111';
##  *** (example of ODBC connection string) - odbc
##  *** $result_conn = $db_conn->connect(DB::parseDSN('odbc://root:12345@test_db'));
##  *** (example of Oracle connection string) - oci8
##  *** 1. $DB_NAME = "localhost:1521/mydatabase";
##  ***    $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:12345@localhost/'.$DB_NAME));
##  *** 2. $DB_DESCR = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = dev.domain.com)))";
##  ***    $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:12345@'.$DB_DESCR));
##  *** (example of PostgreSQL connection string) - pgsql
##  *** $result_conn = $db_conn->connect(DB::parseDSN('pgsql://root:12345@localhost/mydatabase'));
##  *** (example of Firebird connection string)
##  *** $DB_NAME='c:\\program\\firebird21\\data\\db_test.fdb';   
##  *** $db_conn->connect(DB::parseDSN('firebird://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));     
##  === (Examples of connections to other db types see in "docs/pear/" folder)
    $db_conn = DB::factory('mysql');  /* don't forget to change on appropriate db type */
    $result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$EDB_USER.':'.$EDB_PASS.'@'.$EDB_HOST.'/'.$EDB_NAME));
    if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); } 
##  *** write down the primary key in the first place (MUST BE AUTO-INCREMENT NUMERIC!)
    $sql="SELECT min(time) as time_from, max(time) as time_to, max(g.speed) as max_speed, avg(g.speed) as avg_speed, min(g.speed) as min_speed from tms_gpsdata as g where deviceloginname = '".$car_imei."' and g.time > '".$time_from."' and g.time < '".$time_to."' ";
##  *** set needed options and create a new class instance
    $debug_mode = $debug;        /* display SQL statements while processing */   
    $messaging = true;          /* display system messages on a screen */
    $unique_prefix = "move_";    /* prevent overlays - must be started with a letter */
    $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
    $dg_encoding = "utf8";
    $dg_collation = "utf8_unicode_ci";
    $dgrid->SetEncoding($dg_encoding, $dg_collation);
##  *** set data source with needed options
    $default_order_field = ""; /* Ex.: field_name_1 [, field_name_2...] */
    $default_order_type = "ASC";           /* Ex.: ASC|DESC [, ASC|DESC...] */
    $dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);       
##
##
## +---------------------------------------------------------------------------+
## | 2. General Settings:                                                      |
## +---------------------------------------------------------------------------+
## +-- PostBack Submission Method ---------------------------------------------+
##  *** defines postback submission method for DataGrid: AJAX, POST or GET(default)
    $postback_method = "POST";
    $dgrid->SetPostBackMethod($postback_method);
##
## +-- Cache Settings ---------------------------------------------------------+
## *** make sure your cache/ dir has 755 (write) permissions
## *** define caching parameters: 1st - allow caching or not, 2nd - caching lifetime in minutes
    $dgrid->SetCachingParameters(true, 5);
## *** delete all caching pages
    $dgrid->DeleteCache();
##
## +-- Languages --------------------------------------------------------------+
##  *** set interface language (default - English)
##  *** (ar) - Arabic        (bg) - Bulgarian  (ca) - Catala    (ch) - Chinese
##  *** (cz) - Czech         (da) - Danish     (de) - German    (en) - English
##  *** (es) - Espanol       (fr) - Francais   (gk) - Greek     (he) - Hebrew
##  *** (hu) - Hungarian     (hr) - Bosnian/Croatian            (it) - Italiano
##  *** (ja_utf8) - Japanese (lt) - Lithuanian (nl) - Netherlands/"Vlaams"(Flemish)
##  *** (pl) - Polish        (pb) - Brazilian Portuguese        (ro/ro_utf8) - Romanian
##  *** (ru_utf8) - Russian  (se) - Swedish    (sr) - Serbian   (tr) - Turkish                 
    $dg_language = "ru_utf8"; 
    $dgrid->SetInterfaceLang($dg_language);
##  *** set direction: "ltr" or "rtr" (default - "ltr")
/// $direction = "ltr";
/// $dgrid->SetDirection($direction);
##
## +-- Layouts, Templates & CSS -----------------------------------------------+
##  *** datagrid layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized
##  *** use "view"=>"0" and "edit"=>"0" only if you work on the same tables
##  *** filter layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - tabular(inline)
    $layouts = array("view"=>"0", "edit"=>"1", "details"=>"1", "filter"=>"2");
    $dgrid->SetLayouts($layouts);
/// *** $mode_template = array("header"=>"", "body"=>"", "footer"=>"");
/// @field_name_1@ - field header
/// {field_name_1} - field value
/// [ADD][CREATE][EDIT][DELETE][BACK][CANCEL][UPDATE][MULTIROW_CHECKBOX] - allowed elements and operations (must be placed in $template['body'] only)
/// $view_template = "";
/// $add_edit_template = "";
/// $details_template = array("header"=>"", "body"=>"", "footer"=>"");
/// $details_template['header'] = "";
/// $details_template['body'] = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr><tr><td>[BACK]</td></tr></table>";
/// $details_template['footer'] = "";
/// $dgrid->SetTemplates($view_template, $add_edit_template, $details_template);
##  *** set modes for operations ("type" => "link|button|image")
##  *** "view" - view mode | "edit" - add/edit/details modes
##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
$modes = array(
    "add"      =>array("view"=>false, "edit"=>true, "type"=>"link"),
    "edit"     =>array("view"=>false, "edit"=>true,  "type"=>"link", "byFieldValue"=>""),
    "cancel"  =>array("view"=>false, "edit"=>true,  "type"=>"link"),
    "details" =>array("view"=>false, "edit"=>true, "type"=>"link"),
    "delete"  =>array("view"=>false, "edit"=>true,  "type"=>"image"),
);
$dgrid->SetModes($modes);
##  *** set CSS class for datagrid
##  *** "default|blue|gray|green|pink|empty|x-blue|x-gray|x-green" or your own css style
/// $css_class = "default";
/// $dgrid->SetCssClass($css_class);
##  *** set DataGrid caption
    $dg_caption = "Отчёты по движению";
    $dgrid->SetCaption($dg_caption);
##
## +-- Scrolling --------------------------------------------------------------+
##  *** allow scrolling on datagrid
    $scrolling_option = false;
    $dgrid->AllowScrollingSettings($scrolling_option); 
##  *** set scrolling settings (optional)
    $scrolling_height = "100px"; /* ex.: "190px" or "190" */
    $dgrid->SetScrollingSettings($scrolling_height);
##
## +-- Multirow Operations ----------------------------------------------------+
##  *** allow multirow operations
    $multirow_option = false;
    $dgrid->AllowMultirowOperations($multirow_option);
    $multirow_operations = array(
        "edit"    => array("view"=>false),
        "details" => array("view"=>false),
        "clone"   => array("view"=>false),
        "delete"  => array("view"=>false)
        //"my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")
    );
    $dgrid->SetMultirowOperations($multirow_operations); 
##
## +-- Passing parameters & setting up other DataGrids ------------------------+
##  *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
/// $http_get_vars = array("act", "id");
/// $dgrid->SetHttpGetVars($http_get_vars);
##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
##  *** format (in which mode to allow processing of another datagrids)
##  *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
/// $anotherDatagrids = array("abcd_"=>array("view"=>true, "edit"=>true, "details"=>true));
/// $dgrid->SetAnotherDatagrids($anotherDatagrids); 
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings:                                         |
## +---------------------------------------------------------------------------+
##  *** set printing option: true(default) or false
    $printing_option = true;
    $dgrid->AllowPrinting($printing_option);
##  *** set exporting option: true(default) or false and relative (virtual) path
##  *** to export directory (relatively to datagrid.class.php file). Ex.: "export/"
##  *** Add 744 access permissions for this folder.
##  *** Initialize the session. with session_start();
##  *** Ex.: "export/" or "" - if you want to write in current folder
##  *** Change $file_path = "../../".$dir.$file; in scripts/download.php on appropriate path relatively to download.php
    $exporting_option = true;
    $exporting_directory = "export/";               
    $export_all = true;
    $dgrid->AllowExporting($exporting_option, $exporting_directory, $export_all);
    $exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"true");
    $dgrid->AllowExportingTypes($exporting_types);
##
##
## +---------------------------------------------------------------------------+
## | 4. Sorting & Paging Settings:                                             |
## +---------------------------------------------------------------------------+
##  *** set sorting option: true(default) or false
    $sorting_option = false;
    $dgrid->AllowSorting($sorting_option);               
##  *** set paging option: true(default) or false
    $paging_option = false;
    $rows_numeration = false;
    $numeration_sign = "N #";
    $dropdown_paging = false;
    $dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign, $dropdown_paging);
##  *** set paging settings
    $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
    $top_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
    $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
    $default_page_size = 10;
    $paging_arrows = array("first"=>"|&lt;&lt;", "previous"=>"&lt;&lt;", "next"=>"&gt;&gt;", "last"=>"&gt;&gt;|");
    $dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
##

##
##
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings:                                                    |
## +---------------------------------------------------------------------------+
##  *** set view mode table properties
    $vm_table_properties = array("width"=>"90%");
    $dgrid->SetViewModeTableProperties($vm_table_properties); 
##  *** set columns in view mode
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
##  ***      "barchart" : number format in SELECT SQL must be equal with number format in max_value
/// $fill_from_array = array("0"=>"Banned", "1"=>"Active", "2"=>"Closed", "3"=>"Removed"); /* as "value"=>"option" */
$vm_colimns = array(
    "time_from"       =>array("header"=>"От",  "type"=>"label", "align"=>"center",  "wrap"=>"wrap",   "text_length"=>"20", "case"=>"normal"),
    "time_to"       =>array("header"=>"До",  "type"=>"label", "align"=>"center",  "wrap"=>"wrap",   "text_length"=>"20", "case"=>"normal"),
    "max_speed"       =>array("header"=>"Max скорость",  "type"=>"label", "align"=>"center",  "wrap"=>"wrap",   "text_length"=>"20", "case"=>"normal"),
    "avg_speed"     =>array("header"=>"Средняя скорость",  "type"=>"label", "align"=>"center",  "wrap"=>"nowrap", "text_length"=>"20", "case"=>"normal"),
    "min_speed"     =>array("header"=>"Min скорость",  "type"=>"label", "align"=>"center",  "wrap"=>"nowrap", "text_length"=>"20", "case"=>"normal")
   

);
$dgrid->SetColumnsInViewMode($vm_colimns);
##  *** set auto-generated columns in view mode
//  $auto_column_in_view_mode = false;
//  $dgrid->SetAutoColumnsInViewMode($auto_column_in_view_mode);
##
##

##
## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid:                                                     |
## +---------------------------------------------------------------------------+
##  *** bind the DataGrid and draw it on the screen
##  *** to separate binding and displaying use $dgrid->Bind(false) and then $dgrid->Show().
//  $dgrid->WriteCssClass();    /* call of this method between HTML <HEAD> tags */
print_r($_SESSION);
    $dgrid->Bind();             
    ob_end_flush();
?>


if I trying to export table in this code with another $unique_prefix(I mean prefix of another table that exist) - everything good.
Last edited by Mister on Feb 9th, '11, 09:10, edited 1 time in total.

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: Export not working

Postby administrator » Feb 9th, '11, 09:10

$this->GetVariable('export'); means that this parameter sent via URL

Mister
Senior
Senior
Posts: 33
Joined: Dec 8th, '10, 10:05
Location: Ukraine(eastern part of Europe :D ), Kharkiv
Contact:

Re: Export not working

Postby Mister » Feb 9th, '11, 09:58

Unfortunately it didn't help me. Can you say how including code with describing datagrid and way of including datagrid code, which I have described above, can influence on bad behaviour in which result I can't normaly use exporting tables :?: Thank you in advance :!:

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: Export not working

Postby administrator » Feb 13th, '11, 09:58

do you have any Javascript errors on the page you work with? Check with FF Error console. May be a problem comes from the fact, that you work with jQuery


Return to “Settings: Printing & Exporting”