jp
|
| Posted: 05/07/2005, 10:21 PM |
|
Hi everyone, I'm trying to modify the records in a grid to be "Grouped" by a certain field, with a header containing the value to "Group" by.
What I am trying to accomplish is similar "grouping" example in the examples and tutorials section, but also slightly different.
The "grouping" example uses this code to determine when to insert a "header" row:
function departments_BeforeShowRow() {
global $DepName;
global $departments;
if ($DepName == $departments->department_name->GetValue()) {
$departments->department_name->Visible = False;
} else {
$departments->department_name->Visible = True;
$DepName = $departments->department_name->GetValue();
}
}
This results in:
ID Name Title
Finance <---------Group Header Row
2 John Smith Manager
5 Rob McDonald Manager
Software <---------Group Header Row
1 Bob Kuch Sr. Developer
3 Pablo Sanchez Developer
7 David Snyder Developer
Support <---------Group Header Row
6 Stefan Fey Support
Instead, what i want to achieve, is to have the Group header label to be like this:
ID Name Title
Dept: Finance / Type:Manager<---------Group Header Row
2 John Smith
5 Rob McDonald
Dept: Software / Type:Developer<---------Group Header Row
1 Bob Kuch Sr.
3 Pablo Sanchez
7 David Snyder
Dept: Support / Type: Support<---------Group Header Row
6 Stefan Fey
As you notice, instead of being a label connected to a single field, the group header label is now made up of data from a few fields.
Ok i have 2 main areas that I am hazy about.
1. Obviously the groupheader label will no longer have a controlsourcetype of "database column", since instead of being directly linked to a database field, it is now a composite of data from different fields. So what control source type should this new label be?
Should it be "code expression"? If so, what what would i choose for the "control source" ?
2. Secondly, in order to assemble this new header with the composite of data from the different fields,
a) should I use CCDLOOKUP and make a new query to grab the data? or....
b) should i use a method within $departments->ds to grab data? Would this not be a better method considering that all the rows already exist in some array within the $departments grid, this would eliminate the need for a new query caused by CCDLOOKUP for each and every row. For the life of me i can't seem to find the sample code to grab data from the query results array from a grid.
Appreciate any help. Many thanks!
|
|
|
 |
jp
|
| Posted: 05/08/2005, 1:36 AM |
|
actualyl after some reading, I think i kind of understand how to use CCDLOOKUP with the grid ds.
I have a new problem now, how would i be able to display records in the following manner:
ID Name Title
Dept: Finance / Type:Manager<---------Group Header Row
John Smith,Rob McDonald
Dept: Software / Type:Developer<---------Group Header Row
Bob Kuch Sr., Pablo Sanchez, David Snyder
Dept: Support / Type: Support<---------Group Header Row
Stefan Fey
I've been looking at moving the <!-- BEGIN Row --> and <!-- END Row --> template variables around such that they occur within <tr> </tr>,
but for the life of me can't seem to find a solution...
appreciate any help
|
|
|
 |
|