Charly Crembil
|
| Posted: 08/18/2002, 1:58 PM |
|
Hi guys,
I have CC2 and I'm evaluating CCS. But I have a few problems that I want to
share with you, people.
I want to make a grid form, grouping records together (for example, by
customer id). For every group, I want to show a header (with the customer
name, for example) and a footer (with the number of records in this group,
for example). The form needs to be like this:
Customer 1
record 1
record 2
record 3
3 records.
Customer 2
record 4
record 5
2 records.
I've been looking for ways to do this, but the only grid I can do is
something like a plain grid.
It is possible to make this kind of structure with CCS? What's the trick?
Regards,
Carlos.
|
|
|
 |
Chip Cotton
|
| Posted: 08/19/2002, 8:03 AM |
|
Hey copycat! I posted the same question on Friday see:
Stimied: Master / Detail Report (PHP)
Please tell us which language you're working in.
The only solution I've found (so far) is to insert a label underneath
the "Customer" record, create a label attaching it to the index field
of the customers (I'm still waiting on someone giving a working
example of 'ccgetvalue()'), run a query using that variable in the
where clause, then put the results in the label underneath. The count
result would be another query, or you could run a counter as you loop
through the records.
On Sun, 18 Aug 2002 17:56:15 -0300, "Charly Crembil"
<nouser@hotmail.com> wrote:
>Hi guys,
>I have CC2 and I'm evaluating CCS. But I have a few problems that I want to
>share with you, people.
>
>I want to make a grid form, grouping records together (for example, by
>customer id). For every group, I want to show a header (with the customer
>name, for example) and a footer (with the number of records in this group,
>for example). The form needs to be like this:
>
>Customer 1
> record 1
> record 2
> record 3
> 3 records.
>
>Customer 2
> record 4
> record 5
> 2 records.
>
>I've been looking for ways to do this, but the only grid I can do is
>something like a plain grid.
>
>It is possible to make this kind of structure with CCS? What's the trick?
>
>Regards,
>Carlos.
>
|
|
|
 |
Charly Crembil
|
| Posted: 08/19/2002, 11:23 AM |
|
Hi Chip, i'm using PHP4/mysql to run my tests. But if this works, I'll need
to take this
from mysql to DB2.
Well... I'll tell my you my story. I've been thinking in this kind of logic
(just to build the customers
part):
1) build a simple grid, just as I want to show the customer in the same
record.
2) insert a row between the record and the captions, and move the
customer's field to this record. So, for every record inspected, I'll show
two rows: the first one with the customer information, and the second one
with the record information.
3) attach a script after evaluating the record row, equating
"last_customer_id = customer_id"
4) attach a script before evaluating the customer row, considering "if
customer_id = last_customer_id, don't show customer's row".
My doubts:
a) where do I put the after record's script?
b) where do I put the before customer's row script?
c) exists a way to hide just one html row?
Reading the tutorial I've found an interesting part of it, saying you can
hide the entire
form setting "$tasks->Visible = False". I don't like that, because I want to
show the form and what I want to hide is only one row.
So I went deeper, and inspecting the generated code for the grid (inside the
function
Show()). I've found the "Visible" check is made in the beginning, then is
evaluated the BeforeShow event, and then, a do..while starts. Inside the
while is evaluated the BeforeShowRow event, and the HTML is parsed. The only
check to hide something is the "Visible" check, before the while. "Visible"
check, discarded.
After inspecting that, I guess my answers to (a) and (b) will be to put all
the
code in the BeforeShowRow event, "checking first, and then equating". The
check needs to alter a global "rowVisible" variable.
But here is the bad part: answer to (c) is "no", because on the way CCS
works. Every page has an HTML template, and a code block that evaluates this
template. And if your design has two HTML rows, the template associates this
two html rows with just one row of data (the template has a "Begin Row ...
End Row" section, grouping this HTML code).
The only workaround I can think is (put your gloves, and prepare to
develope):
- edit the template, and break the "Begin Row ... End Row" section of the
template, into a "Begin Row1 .. End Row1, Begin Row2 .. End Row2" sections.
The first one with the customer's part, and the second one with the record's
part.
- edit the Show() function in your Code view
+ adjusting the $Tpl->parse() argument to point to the new "Row2"
+ duplicating this line, putting it before and adjust the argument to
"Row1"
+ inserting a kind of "if" before, that parses the "Row1" line only if a
"rowVisible" variable lets you do so.
As you can imagine, you'll be changing a lot of code, and I don't know what
kind of impact can this do in the rest of your project (for example: will
you loose all your show() modifications when you add a new field?).
I'll appreciate if any CCS developer wants to answer me if CCS admits this
kind of changes (changing the template, and changing the code that evaluates
the template).
Regards,
Carlos.
"Chip Cotton" <please.no.email@Jail-Spammers.com> escribió en el mensaje
news:ru12muosl83bfh5qh74nscug42fdtn2s15@4ax.com...
> Hey copycat! I posted the same question on Friday see:
> Stimied: Master / Detail Report (PHP)
>
> Please tell us which language you're working in.
>
> The only solution I've found (so far) is to insert a label underneath
> the "Customer" record, create a label attaching it to the index field
> of the customers (I'm still waiting on someone giving a working
> example of 'ccgetvalue()'), run a query using that variable in the
> where clause, then put the results in the label underneath. The count
> result would be another query, or you could run a counter as you loop
> through the records.
>
> On Sun, 18 Aug 2002 17:56:15 -0300, "Charly Crembil"
> <nouser@hotmail.com> wrote:
>
> >Hi guys,
> >I have CC2 and I'm evaluating CCS. But I have a few problems that I want
to
> >share with you, people.
> >
> >I want to make a grid form, grouping records together (for example, by
> >customer id). For every group, I want to show a header (with the customer
> >name, for example) and a footer (with the number of records in this
group,
> >for example). The form needs to be like this:
> >
> >Customer 1
> > record 1
> > record 2
> > record 3
> > 3 records.
> >
> >Customer 2
> > record 4
> > record 5
> > 2 records.
> >
> >I've been looking for ways to do this, but the only grid I can do is
> >something like a plain grid.
> >
> >It is possible to make this kind of structure with CCS? What's the trick?
> >
> >Regards,
> >Carlos.
> >
>
|
|
|
 |
Chip Cotton
|
| Posted: 08/19/2002, 11:59 AM |
|
Charly: Read my notes, but I'm not *sure* what you're looking to do.
I'm THINKING you want to hide the *repeat* of a customer's name from a
recordset (which is a snap in MS Access or Crystal Reports) so you can
use the customer's name (say) as a 'header' for the first row of
details (a common accounting format). Let me know if this is what
you're looking to do...
On Mon, 19 Aug 2002 15:21:31 -0300, "Charly Crembil"
<nouser@hotmail.com> wrote:
> 1) build a simple grid, just as I want to show the customer in the same
>record.
>
> 2) insert a row between the record and the captions, and move the
>customer's field to this record. So, for every record inspected, I'll show
>two rows: the first one with the customer information, and the second one
>with the record information.
>
> 3) attach a script after evaluating the record row, equating
>"last_customer_id = customer_id"
>
> 4) attach a script before evaluating the customer row, considering "if
>customer_id = last_customer_id, don't show customer's row".
>
>My doubts:
>a) where do I put the after record's script?
>b) where do I put the before customer's row script?
>c) exists a way to hide just one html row?
OK, the problem I see is that I don't see how CCS lets you insert one
recordset / result inside another (master/detail). In hardcoded PHP,
this is easy enough, but I can understand that, given the tools
presented, CCS doesn't let you do this with the components.
My solution has been (am I repeating myself?) to put a label next to /
underneath the customer, making the value of that label the identity
column of the customer. In the beforeshow event of that label, put
this kind of code in:
global $frm_customers_w_detail; // declare the form
$sqlvar = $frm_customers_w_detail->c_id->getvalue(); //get the key
value assigned to that customer...
//untested SQL hacked from another working example - don't use
$SQL = "SELECT `customers`.`c_id`,`sales`.`amount`
FROM `sales`
INNER JOIN `customers` ON (`customers`.`c_id` = `sales`.`c_id`)
WHERE
((`customers`.`c_id` = $sqlvar))";
$result = mysql_query($SQL);
while ($row = mysql_fetch_object($result)) {
$output = $output . '<br> ' . $row->amount; //put the
formatted output into a variable
}
mysql_free_result($result);
// set the label's value the output from the query
$frm_customers_w_detail->c_id->setvalue($output);
// end of code snip
The total or other aggregate function would be the result of another
SQL given the $sqlvar...
If you're thinking in terms of Crystal Reports, where you can simply
hide repeats of the master table off of a single SQL recordset, this
is frustrating, because this method means you have to fire off an SQL
for every customer's record.
I'm open to alternatives, but this one works.
>But here is the bad part: answer to (c) is "no", because on the way CCS
>works. Every page has an HTML template, and a code block that evaluates this
>template. And if your design has two HTML rows, the template associates this
>two html rows with just one row of data (the template has a "Begin Row ...
>End Row" section, grouping this HTML code).
I'm thinking you want to look at the HTML code for the <!-- begin this
section--> comments to see how the rows behave...
I hope that we can discover a less involved method than the direction
you're going into with the rest of your message...
|
|
|
 |
donb
|
| Posted: 08/19/2002, 1:03 PM |
|
While there is no auto-generated solution, I've been thinking about this for
a while. My desired goal would be to spit out a nice XML tree to show the
parent-child relationships. The alternative (which I feel is more within my
abilities) is to fiddle with the alternate-row mechanism that CCS provides.
I think the intended purpose was to to the "green bar" style alternating row
appearance you see a lot of. However, it occurs to me that this could form
the basis for a sophisticated grouping mechanism. Fundamentally, there is
nothing that looks like it would prevent you from doing this. In reality,
there are probably several pitfalls waiting for us to become the
unsuspecting victims.
Here's my idea: The alternating row code is pretty simplistic. It just
toggles a boolean to decide which row to output. By default, both rows have
the same layout and derive data from the same commection/recordset. Why
does that have to be? We could put a second connection for the child data,
then add a second loop to process that data. The toggle would be done based
on when we hit the last row of the child recordset. Since there are two
RowControl objects, we should be able to put whatever we want into the "alt"
object. So it should be possible to toggle between parent and child data
rows about as easily as toggling the background color, font or whatever.
As I said, "in theory", we ought to be able to kick in the "alt" row of
child records each time we step to a new parent row - giving a table of one
parent followed by n child records, repeated for the entire parent record
set. Now, paging is the first thing that looks like trouble. I don't know
what that would actually look like, and I'd really want to avoid having the
page break in the middle of a child's rows. perhaps the paging mechanism
(the Navigator object) could be adapted to ignore child rows altogether.
Any way, food for thought.
don
"Chip Cotton" <please.no.email@Jail-Spammers.com> wrote in message
news:gre2muko0ud48q9aoa98oflfbqmsm3b1d2@4ax.com...
> Charly: Read my notes, but I'm not *sure* what you're looking to do.
>
> I'm THINKING you want to hide the *repeat* of a customer's name from a
> recordset (which is a snap in MS Access or Crystal Reports) so you can
> use the customer's name (say) as a 'header' for the first row of
> details (a common accounting format). Let me know if this is what
> you're looking to do...
>
> On Mon, 19 Aug 2002 15:21:31 -0300, "Charly Crembil"
> <nouser@hotmail.com> wrote:
>
> > 1) build a simple grid, just as I want to show the customer in the
same
> >record.
> >
> > 2) insert a row between the record and the captions, and move the
> >customer's field to this record. So, for every record inspected, I'll
show
> >two rows: the first one with the customer information, and the second one
> >with the record information.
> >
> > 3) attach a script after evaluating the record row, equating
> >"last_customer_id = customer_id"
> >
> > 4) attach a script before evaluating the customer row, considering
"if
> >customer_id = last_customer_id, don't show customer's row".
> >
> >My doubts:
> >a) where do I put the after record's script?
> >b) where do I put the before customer's row script?
> >c) exists a way to hide just one html row?
>
> OK, the problem I see is that I don't see how CCS lets you insert one
> recordset / result inside another (master/detail). In hardcoded PHP,
> this is easy enough, but I can understand that, given the tools
> presented, CCS doesn't let you do this with the components.
>
> My solution has been (am I repeating myself?) to put a label next to /
> underneath the customer, making the value of that label the identity
> column of the customer. In the beforeshow event of that label, put
> this kind of code in:
>
> global $frm_customers_w_detail; // declare the form
>
> $sqlvar = $frm_customers_w_detail->c_id->getvalue(); //get the key
> value assigned to that customer...
>
> //untested SQL hacked from another working example - don't use
>
> $SQL = "SELECT `customers`.`c_id`,`sales`.`amount`
> FROM `sales`
> INNER JOIN `customers` ON (`customers`.`c_id` = `sales`.`c_id`)
> WHERE
> ((`customers`.`c_id` = $sqlvar))";
>
> $result = mysql_query($SQL);
>
> while ($row = mysql_fetch_object($result)) {
> $output = $output . '<br> ' . $row->amount; //put the
> formatted output into a variable
> }
> mysql_free_result($result);
>
> // set the label's value the output from the query
> $frm_customers_w_detail->c_id->setvalue($output);
>
> // end of code snip
>
> The total or other aggregate function would be the result of another
> SQL given the $sqlvar...
>
> If you're thinking in terms of Crystal Reports, where you can simply
> hide repeats of the master table off of a single SQL recordset, this
> is frustrating, because this method means you have to fire off an SQL
> for every customer's record.
>
> I'm open to alternatives, but this one works.
>
> >But here is the bad part: answer to (c) is "no", because on the way CCS
> >works. Every page has an HTML template, and a code block that evaluates
this
> >template. And if your design has two HTML rows, the template associates
this
> >two html rows with just one row of data (the template has a "Begin Row
....
> >End Row" section, grouping this HTML code).
>
> I'm thinking you want to look at the HTML code for the <!-- begin this
> section--> comments to see how the rows behave...
>
> I hope that we can discover a less involved method than the direction
> you're going into with the rest of your message...
|
|
|
 |
|