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 
passing values not showing up in the datagrid

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



Joined: 23 Nov 2007
Posts: 7

PostPosted: Fri Nov 23, 2007 4:41 am    Post subject: passing values not showing up in the datagrid Reply with quote

I am using smarty as the renderer and I want to pass an ID but not show it in the rendered datagrid. Here is an example of my sql..

Code:
$dg->bind("SELECT id, title, location FROM jobs", $bind_options, DATAGRID_SOURCE_MDB2);


Is there a way to do this?

THanks
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sat Nov 24, 2007 12:35 am    Post subject: Reply with quote

Simply add the columns yourself. (If you don't do it, SDG will add columns for every column in your SQL query.)
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Sat Nov 24, 2007 6:08 am    Post subject: Reply with quote

I guess another question I have is how to add all three columns to the smarty object with out displaying it in the datagrid
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sat Nov 24, 2007 10:41 am    Post subject: Reply with quote

cfletcher1856 wrote:
I guess another question I have is how to add all three columns to the smarty object with out displaying it in the datagrid


The data should still be available in the renderer (e.g. Smarty), even if you output just one column but fetch e.g. five columns from the database.
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Sat Nov 24, 2007 6:13 pm    Post subject: Reply with quote

The data is not in the renderer. The only things that get set in the smarty renderer are the values that are selected in the sql or that you create columns for.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sat Nov 24, 2007 9:37 pm    Post subject: Reply with quote

cfletcher1856 wrote:
The only things that get set in the smarty renderer are the values that are selected in the sql [...]


Well isn't that exactly what you wanted to have? Please provide an example if it isn't.
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Sun Nov 25, 2007 5:05 am    Post subject: Reply with quote

I want to use this sql

Code:
$dg->bind("SELECT id, title, location FROM jobs", $bind_options, DATAGRID_SOURCE_MDB2);


and have the datagrid look like this
Code:


+----------+-----------+
|   Title     |  Location |
+----------+-----------+
|value      | value      |
+----------+-----------+

In the smart object I want each ID with out its display in the rendered datagrid.
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Tue Nov 27, 2007 3:51 pm    Post subject: Reply with quote

so i am guessing no one knows how to do this. I think this should be added as a feature in a future release of the smarty renderer.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Tue Nov 27, 2007 7:48 pm    Post subject: Reply with quote

More patience please. Smile

Maybe we're talking about different things, but the data *is* available. Every field that you select in your SQL query is available in formatters.

Therefore, if you e.g. add a column for one of the fetched field and another "dummy" column that uses a formatter function, this formatter function has access to every of the fetched fields.
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Wed Nov 28, 2007 12:21 am    Post subject: Reply with quote

What do you mean dummy column? I dont really understand your answer at all.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Wed Nov 28, 2007 12:44 am    Post subject: Reply with quote

cfletcher1856 wrote:
What do you mean dummy column? I dont really understand your answer at all.


"Dummy" was meant in the way that the column is not directly related to a field in your SQL query. Let's assume that you have added one ore more columns that are related to the SQL query (in your example e.g. title and location). Now you can do something like this:
Code:

$column = new Structures_DataGrid_Column('Title', 'title', 'title', array('align' => 'center'), 'N/A', 'formatter');
$dg->addColumn($column);


Note that all strings and the attributes array in this code sample are just examples, change them to your needs. This is also true for the name of the formatter function, 'formatter' is maybe not the best name.

Now you need to define this formatter function:
Code:

function formatter($params)
{
    var_dump($params);
    return 'example123';
}


This new column will then show 'example123' in every row, but also multiple times the data that is stored in $params. Look at it -- it contains the values that you're looking for. Then, make the function do what you need.
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