| View previous topic :: View next topic |
| Author |
Message |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Fri Nov 23, 2007 4:41 am Post subject: passing values not showing up in the datagrid |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sat Nov 24, 2007 12:35 am Post subject: |
|
|
| 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 |
|
 |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Sat Nov 24, 2007 6:08 am Post subject: |
|
|
| 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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sat Nov 24, 2007 10:41 am Post subject: |
|
|
| 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 |
|
 |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Sat Nov 24, 2007 6:13 pm Post subject: |
|
|
| 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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Sat Nov 24, 2007 9:37 pm Post subject: |
|
|
| 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 |
|
 |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Sun Nov 25, 2007 5:05 am Post subject: |
|
|
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 |
|
 |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Tue Nov 27, 2007 3:51 pm Post subject: |
|
|
| 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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Tue Nov 27, 2007 7:48 pm Post subject: |
|
|
More patience please.
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 |
|
 |
cfletcher1856
Joined: 23 Nov 2007 Posts: 7
|
Posted: Wed Nov 28, 2007 12:21 am Post subject: |
|
|
| What do you mean dummy column? I dont really understand your answer at all. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Wed Nov 28, 2007 12:44 am Post subject: |
|
|
| 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 |
|
 |
|