PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
[Solved] DataGrid, Quickform and ::AddColumn()

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures
View previous topic :: View next topic  
Author Message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Wed Sep 13, 2006 5:10 pm    Post subject: [Solved] DataGrid, Quickform and ::AddColumn() Reply with quote

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
View user's profile Send private message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Thu Sep 21, 2006 1:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Jan 07, 2007 6:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Tue Jul 03, 2007 12:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Tue Jul 03, 2007 5:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Tue Jul 03, 2007 5:46 pm    Post subject: Reply with quote

Mark, I m aware about DBDO, thanks Smile
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
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Tue Jul 03, 2007 5:50 pm    Post subject: Reply with quote

alex wrote:
Mark, I m aware about DBDO, thanks Smile
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
View user's profile Send private message
alex



Joined: 13 Sep 2006
Posts: 72

PostPosted: Tue Jul 03, 2007 5:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software