add export to cvs to datagrid - plugin in test
Before I propose a plugin, I think will be better to give QDataGridExporter to test with manual installation instruction.
Button is only test (I posted a ticket to add image to button, but at moment buttons works only with test inside).
Manual installation.
Now in my working installation of qcubed_110 there is the new class
..\includes\qcubed\plugins\QDataGridExporter\includes\QDataGridExporter.class.php
I added by hand info to the new class in plugin_includes.php, so I can proceed.
Test path.
I used the person_list.php in drafts to test (this test breaks the rule to not change generated object!!!)
1- add button creation in PersonListFormBase.class.php (form is in \includes\formbase_classes_generated\
class PersonListFormBase extends QForm {
change to public from protected $dtgPeople
public $btnCVS;
.....
protected function Form_Create() {
.....
.....
......
$this->btnCVS = new DataGridExporter($this->dtgPeople);
....2- add render in person_list.tpl.php (this is in \drafts)
<?php $this->btnCVS->Render(); ?>
Now I changed some (not all necessary -sorry !) function to public in QDataGridBase.class.php
public $objColumnArray;
public function GetHeaderRowHtml()
public function GetControlHtml()
Button is present and if you push it file 2010-01-07_datagrid_export.csv is created...
and also adding the button in other listform works....
That's all for today, folks. Gianni

Gianni - I'm super-thrilled to see you're making great progress. Before we go ahead and test this, can you talk about the changes you made to QDataGridBase.class.php? Why were they necessary?
Idea: it looks like you accessed the contents of the datagrid by getting its ControlHTML (by calling GetControlHTML() on it). Why not use the raw DataSource property? You won't have to do any HTML parsing in that case.
I believe this is because the datagrid has a lot of display related information (what columns to show, what to output for each) that simply isn't included in the DataSource.
I was not able to get data using raw DataSource so after a long investigation I resorted in using (bleeding) the two functions.
During investigation I found that before
$this->datasource->DataBind();
to have data in my output I must insert
$this->datasource->SetDataBinder('MetaDataBinder', $this->datasource);
$this->datasource->ItemsPerPage = 2147483647;
$this->datasource->PageNumber = 1;
// next line is fundamental and key of the result at the end of my efforts //
$this->datasource->SetDataBinder('MetaDataBinder', $this->datasource);
$this->datasource->DataBind();
so now the proposed experimental plugin works.
I admit that when I saw data coming from GetControlHTML() , I not retried regression experiments on DataSource.
Thanks for your assistance in find how to remove my bleeding actions on QDataGridBase.class.php.
Ciao, Gianni
Gianni - I don't completely understand. Were you able to go away from having to change QDataGridBase.class.php? If so, do you want to upload a cleaned-up version of your class that does not require modifications to QDataGridBase.class.php? There's a lot of commented out code in your uploaded zip, it might make sense to clean it up a bit before having folks review it. Could you do that?
Thanks!
-Alex
Hello Alex,
The last task you assigned ... completed (I hope).
I rethinked a little what I learnt in my test with your precious guide and, with some little intervention on code, in final code no intervention is required (now no blood) in QDataGridBase.class.php.
I did change comment in initial post to reflect this and reattached the plugin leaving in zip also the bleeding old (as note of my voyage in OOP).
Now I am very satisfied (Alex, you also!!) and I'll take a short rest.....
Gianni.