| View previous topic :: View next topic |
| Author |
Message |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Wed Sep 13, 2006 5:10 pm Post subject: [Solved] DataGrid, Quickform and ::AddColumn() |
|
|
Hi,
I read this tutorial (http://www.samalyse.com/code/pear/dgdo/index.fr.php) and understood most things.
then I tried to add a form with checkboxes on the right. I tried to add a column with the addColum method but I only managed to auto-fill. Moreover I won't be able to combine HTML_FORM/quickform.
Maybe it should be added to the data set ... but how ...
Does anybody could show me the way to do it ?
Thanks
Last edited by alex on Tue Jul 03, 2007 6:00 pm; edited 2 times in total |
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Thu Sep 21, 2006 1:58 pm Post subject: |
|
|
I got it working but using the addColumn method doesn't just add a column to the table renderer : it adds but makes the rest of the columns (existing colums) disappear !! They talk about that in Structure_DataGrid FAQ in the third question but don't renderer the datagrid.
Apperently, it is not possible to directly renderer a datagrid when adding a column ; the only way seems to add a HTM_Table object and then use the "Structure_DataGrid::fill" method for table (and pager eventually). It takes more lines and time :\
Is there a issue for this or is this the only way to add a column ?
Thanks. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Sun Jan 07, 2007 6:48 pm Post subject: |
|
|
| This question is rather old, but if there is still a need for help on this, I can give you some more information on this. |
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Tue Jul 03, 2007 12:12 pm Post subject: |
|
|
Hi Mark ! Thanks for digging out !
Well, now I practice like that ; do you think it is good ?
| Code: | <?php
// .....
//$do is a PEAR data object
$query = "SELECT * ... "
$datagrid =& new Structures_DataGrid();
$datagrid->bind($query,$do->getDatabaseConnection());
//Columns
$column = array();
$column[] = new Structures_DataGrid_Column('col_1 .....');
//....
$column[] = new Structures_DataGrid_Column('co_ln .....');
foreach ($column as $k=>$c) {
$datagrid->addColumn($column[$k]);
}
//Use smarty
$datagrid->fill($smartyRenderer);
//.......
?> |
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Tue Jul 03, 2007 5:20 pm Post subject: |
|
|
| alex wrote: | Hi Mark ! Thanks for digging out !
Well, now I practice like that ; do you think it is good ? |
Alex, your code snippet is rather short, but looks okay. Are you aware that there is a DataSource driver for DB_DataObject (DBDO)? Using SQL queries in bind() is perfectly fine, of course, but if you are using DBDO in your code, you might consider to use it also in the bind() call.
Do need more help on your initial questions in this thread?
BTW, there is a new CheckableHTMLTable renderer in CVS that might be interesting for you in regard to your initial question. |
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Tue Jul 03, 2007 5:46 pm Post subject: |
|
|
Mark, I m aware about DBDO, thanks
I use it (there is one in my previous code used to recall the db connection). However there is a "bug" in the pager count when "SELECT" contains "COUNT() ...". The pager link prints wrong values ! I posted in bug report ... but I don't find it anymore on the PEAR website :\ There were a answer to say it was "normal" ; I can't remember the real reason. So I was urged to bind() like that ... too bad :\ Have you ever heard about that ? But it is another subject ...
For the initial question, what is the CheckableHTMLTable renderer supposed to do ? I will check it out, thanks. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Tue Jul 03, 2007 5:50 pm Post subject: |
|
|
| alex wrote: | Mark, I m aware about DBDO, thanks
I use it (there is one in my previous code used to recall the db connection). |
Yes, I saw that, and that's why I wanted to point you to the fact that you can pass a DBDO instance to bind(). (But I must admit that I don't use DBDO myself.)
| alex wrote: | | However there is a "bug" in the pager count when "SELECT" contains "COUNT() ...". The pager link prints wrong values ! I posted in bug report ... but I don't find it anymore on the PEAR website :\ There were a answer to say it was "normal" ; I can't remember the real reason. |
I don't remember such a report, sorry. Can you please open a new bug report or send me an email with a short code example or at least with a SQL query that shows the problem?
| alex wrote: | | For the initial question, what is the CheckableHTMLTable renderer supposed to do ? |
It adds a checkbox to each row of the table. You were talking about something like that in the initial post. |
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Tue Jul 03, 2007 5:56 pm Post subject: |
|
|
Yes, I will send you a email (or MP) with a quick example.
For the initial question, you answered ... I will look at the "CheckableHTMLTable renderer" in CVS
Thanks. |
|
| Back to top |
|
 |
|