CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Alternating Rows in Grid, the easy way.

Print topic Send  topic

Author Message
Walter Kempees
Posted: 12/22/2005, 10:03 AM


Objective:
In CCS you have a choice on Grid's of using "alternate records", this will
give your grid a professional look, visualy separating rows of data.
The disadvantage of this solution is that all fields in the grid are
duplicated, leaving us with a lot of work in case a BeforeShowRow needs to
alter data, fields have to be added to the table and similar actions.
So, for all of us who don't need to do any actions on the data that differs
between a normal and an alternate record, this solution might be helpfull.

STEP 1:
Generate your Grid as you normally would and leave the checkbox "alternate
records" unchecked, empty.

STEP2:
Open your page containing the Grid in HTML mode and find <!-- BEGIN
Row -->.
On the next but one line you will see
 <tr class="Row"> 
.
Select the
 class="Row" 
bit including the "
From the Toolbox->Forms select "A Label", which would result in something
like:
 <tr {Label1}> 
.
In the Properties of the Label, (optionally) change the name of the label to
anything you like (I use LblRowClass) and set Content to HTML, leaving all
other options default.

STEP 3:
Switch to designer mode.
Select the Grids Properties->Events->BeforeShowRow
Insert the following code: PHP, ASP or other flavours anyone?
  
//Custom Code @25-2A29BDB7  
// -------------------------  
    // Write your own code here.  
// -------------------------  
   global $RowCount;  
   $RowCount += 1;  
   if ($RowCount %2 ==0)  
      $Component->LblRowClass->SetValue('class="Row"');  
   else  
      $Component->LblRowClass->SetValue('class="AltRow"');  
  
//End Custom Code  

Note The SetValue does end in double quotation and single quotation marks.
This snippet would be placed before any other custom coding.

PUBLISH your page, et voíla, alternate records without code duplication
(actualy containing differences).

Walter Kempees
Consultair Nederland BV









Benjamin Krajmalnik
Posted: 12/22/2005, 12:10 PM

Walter,

I have implemented in a slightly different way. Instead of performing a mod
operation I change a bit status, which is a bit faster (not that it will be
noticeable, but every nanosecond counts! :)

global $isAltRow;
$Component->LblRowClass->SetValue('class="Row"');
if($isAltRow) {
$Component->LblRowClass->SetValue('class="AltRow"');
}
$isAltRow = (!$isAltRow);


Walter Kempees
Posted: 12/23/2005, 3:17 AM

Nice.
Thanks.
Walter
"Benjamin Krajmalnik" <kraj@illumen.com> schreef in bericht
news:dof178$7v4$1@news.codecharge.com...
> Walter,
>
> I have implemented in a slightly different way. Instead of performing a
> mod
> operation I change a bit status, which is a bit faster (not that it will
> be
> noticeable, but every nanosecond counts! :)
>
> global $isAltRow;
> $Component->LblRowClass->SetValue('class="Row"');
> if($isAltRow) {
> $Component->LblRowClass->SetValue('class="AltRow"');
> }
> $isAltRow = (!$isAltRow);
>
>
>

Damian Hupfeld
Posted: 01/08/2006, 9:14 PM

Works a treat gentlemen.
And so many times easier than the builtin Alt_Rows feature.

Damian


"Walter Kempees" <kempe819@planet.nl> wrote in message
news:dogmce$ql$1@news.codecharge.com...
> Nice.
> Thanks.
> Walter
> "Benjamin Krajmalnik" <kraj@illumen.com> schreef in bericht
>news:dof178$7v4$1@news.codecharge.com...
>> Walter,
>>
>> I have implemented in a slightly different way. Instead of performing a
>> mod
>> operation I change a bit status, which is a bit faster (not that it will
>> be
>> noticeable, but every nanosecond counts! :)
>>
>> global $isAltRow;
>> $Component->LblRowClass->SetValue('class="Row"');
>> if($isAltRow) {
>> $Component->LblRowClass->SetValue('class="AltRow"');
>> }
>> $isAltRow = (!$isAltRow);
>>
>>
>>
>
>

Benjamin Krajmalnik
Posted: 01/10/2006, 8:34 AM

Absolutely, since now you manage one set of controls.
I had a very complex page with multiple child tables (grids) in it.
WHen I would go into design mode the html would invariable get corrupted.
After deleting half of the controls by using this method I no longer have
the problem.


Walter Kempees
Posted: 01/10/2006, 8:58 AM

y'all putta smile on my face.

"Benjamin Krajmalnik" <kraj@illumen.com> schreef in bericht
news:dq0nne$34m$1@news.codecharge.com...
> Absolutely, since now you manage one set of controls.
> I had a very complex page with multiple child tables (grids) in it.
> WHen I would go into design mode the html would invariable get corrupted.
> After deleting half of the controls by using this method I no longer have
> the problem.
>
>
>

peterr


Posts: 5971
Posted: 01/11/2006, 1:25 PM

Hi,
I learned that we considered similar method for CCS1 but there was no easy way to visually represent such rows in Design view and allow users to visually modify alternate rows if needed. But since this methods seems useful we can add it as an option in CCS Grid Builder. Please let us know your opinion.
Thanks.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Walter Kempees
Posted: 01/11/2006, 1:45 PM

Yes please.
Would save me a lot of time.
I cannot figure a reason to have different dtarepresentation, or before /
after handling in a row or alt_row.
If you generate a grid with alternate rows and after a while have to change
anything, you're in for a suprise, at least that's what motivated me to
propose the solution.
The Highlighting a row (and even selecting it by clicking) could be added to
the css (stylesheet) by anyone when needed.
Although adding that as a selectable option would be even greater, do you
use PhPAdmin? then you know what I mean.

Thanks for considering.
Walter


"peterr" <peterr@forum.codecharge> schreef in bericht
news:2543c577e2045fa@news.codecharge.com...
> Hi,
> I learned that we considered similar method for CCS1 but there was no easy
> way
> to visually represent such rows in Design view and allow users to visually
> modify alternate rows if needed. But since this methods seems useful we
> can
> add it as an option in CCS Grid Builder. Please let us know your opinion.
> Thanks.
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Benjamin Krajmalnik
Posted: 01/11/2006, 7:08 PM

Automating this would be great.
As Walter mentioned, the alternate row is simply a different "colorization"
of the row. The problem in maintaining the alt rows as currently generated
is that now you have to go in and duplicate any changes you make to one row.
The more event code you have the more changes you need to make.
Currently, the IDE recognizes the existance of the Alt_Row tag in the html
and adds a flag field and associated code to hide/display the correct row.
I think this method is a more elegant solution, results in tighter code, and
much less of a maintenance headache.


Damian Hupfeld
Posted: 01/12/2006, 3:10 AM

I have found the alternating rows useful for doing things like:

{row} image | text text text text
{altrow} text text text text | image

but otherwise find it really difficult when you do want to go back and
change things later on. 9/10 of my altrows are used to make reading the data
easier and not to change the layout.

having it as an option so that you can use the Yes method or the Walter
method at creation would be a great solution.

Damian


"peterr" <peterr@forum.codecharge> wrote in message
news:2543c577e2045fa@news.codecharge.com...
> Hi,
> I learned that we considered similar method for CCS1 but there was no easy
> way
> to visually represent such rows in Design view and allow users to visually
> modify alternate rows if needed. But since this methods seems useful we
> can
> add it as an option in CCS Grid Builder. Please let us know your opinion.
> Thanks.
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

marcwolf


Posts: 361
Posted: 01/12/2006, 4:56 PM

<Puts up his Paw>

Yes Please Peter

We have dropped uisng AltRows unless there is a very particular reason.

Saves a lot of program code when one is doing specialised links, images etc too.

Take Care
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
DonB
Posted: 01/18/2006, 5:54 PM

I've been doing the same thing for a long time, although I have implemented
it just slightly differently, so I have to do less typing:

For my grids, this is all I have to change each time:

1. Add {rowcolor} template tag to the <tr> of my 'row' block
2. Add BeforeShowRow event
3. Call my function ToggleRowColor() in the event
4. Declare the two CSS classes 'ltrow' and 'dkrow" with appropriate colors
for the two rows


The function ToggleRowColor (for PHP) is:

$thisRow = 0;
function ToggleRowColor() {
global $thisRow;
global $Tpl;

$thisRow = !$thisRow;
if ($thisRow) {
$Tpl->SetVar("rowcolor", "class='ltrow'");
}
else {
$Tpl->SetVar("rowcolor", "class='dkrow'");
}
}

The function is a bit different for ASP, as I pass the Eventcaller object
(which at the time seemed to simplify accessing template tags:

Dim thisRow
function ToggleRowColor(e)

Dim t
set t = e.TemplateBlock

thisRow = not thisRow

if (thisRow) Then
t.block("Row").Variable("rowcolor") = "class='ltrow'"
Else
t.block("Row").Variable("rowcolor") = "class='dkrow'"
End If

set t = Nothing

End Function

I put these functions into Common.php/Common.asp so they are always
available and I don't have to do lots of 'includes'. Note how 'thisRow' is
declared OUTSIDE of the functions, so it remains defined between each
execution of the Before Show Row event.

This could all be made even simpler by editing the class definition of the
Grid/ Editable Grid, but I dislike making changes to the 'standard' CCS
code. Having the variable and function as class members would streamline
things a lot.
--
DonB

http://www.gotodon.com/ccbth


"Walter Kempees" <kempe819@planet.nl> wrote in message
news:doepor$3l8$1@news.codecharge.com...
>
> Objective:
> In CCS you have a choice on Grid's of using "alternate records", this will
> give your grid a professional look, visualy separating rows of data.
> The disadvantage of this solution is that all fields in the grid are
> duplicated, leaving us with a lot of work in case a BeforeShowRow needs to
> alter data, fields have to be added to the table and similar actions.
> So, for all of us who don't need to do any actions on the data that
differs
> between a normal and an alternate record, this solution might be helpfull.
>
> STEP 1:
> Generate your Grid as you normally would and leave the checkbox "alternate
> records" unchecked, empty.
>
> STEP2:
> Open your page containing the Grid in HTML mode and find <!-- BEGIN
> Row -->.
> On the next but one line you will see
 <tr class="Row"> 
.
> Select the
 class="Row" 
bit including the "
> From the Toolbox->Forms select "A Label", which would result in something
> like:
 <tr {Label1}> 
.
> In the Properties of the Label, (optionally) change the name of the label
to
> anything you like (I use LblRowClass) and set Content to HTML, leaving all
> other options default.
>
> STEP 3:
> Switch to designer mode.
> Select the Grids Properties->Events->BeforeShowRow
> Insert the following code: PHP, ASP or other flavours anyone?
>
  
> //Custom Code @25-2A29BDB7  
> // -------------------------  
>     // Write your own code here.  
> // -------------------------  
>    global $RowCount;  
>    $RowCount += 1;  
>    if ($RowCount %2 ==0)  
>       $Component->LblRowClass->SetValue('class="Row"');  
>    else  
>       $Component->LblRowClass->SetValue('class="AltRow"');  
>  
> //End Custom Code  
> 
>
> Note The SetValue does end in double quotation and single quotation marks.
> This snippet would be placed before any other custom coding.
>
> PUBLISH your page, et voíla, alternate records without code duplication
> (actualy containing differences).
>
> Walter Kempees
> Consultair Nederland BV
>
>
>
>
>
>
>
>
>
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.