Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating Group(s) on DataWindow @ runtime

461 views
Skip to first unread message

Taufiq Ahmed

unread,
Apr 10, 2004, 4:25:07 AM4/10/04
to
Hi

I'm using PB803-9704. I want to Create Group on DataWindow at runtime just
as we are doing for sorting & filtering using SetSort(), Sort() &
SetFilter(), Filter. Is there any possibility as I need this functionality
in so many reports.


Regards,

Taufiq Ahmed

Ken Drendel

unread,
Apr 12, 2004, 1:30:33 PM4/12/04
to
Use a computed column in the group definition. Then dynamically set the
expression to the column/combination of column(s) that you want to group by.


Ken Drendel

On 10 Apr 2004 00:25:07 -0800,
in sybase.public.powerbuilder.datawindow

John Olson [Team Sybase]

unread,
Apr 12, 2004, 1:37:02 PM4/12/04
to
Group manipulation is limited at RunTime. Here's an article that will
provide some helpful tips:

http://eric.aling.tripod.com/PB/tips/pbtip07.htm

Regards,
John
Team Sybase


"Taufiq Ahmed" <taufi...@autosoftdynamics.com> wrote in message
news:4077a153@forums-1-dub...

Ken Judkins

unread,
Apr 13, 2004, 10:17:19 AM4/13/04
to
I have a window that allows users to create their own report from scratch.
They are allowed to create a single group level on the fly. Here is the
code for the event that adds a group to the datawindow.

//-------------------------------------------------------------------------/
/
DataStore lds_temporary_storage
Long ll_syntax_len, ll_index, ll_target_object_len, ll_open_parenthesis,
ll_i
String ls_band, ls_syntax_before, ls_syntax_after, ls_syntax_new, ls_syntax,
ls_target_object
String ls_test, ls_this_character, ls_msg

IF UpperBound( is_object_name ) = 1 THEN
ls_band = This.Describe( is_object_name[ 1 ] + ".Band" )
IF Lower( ls_band ) = "detail" THEN
If IsValid (inv_expression) Then

ls_syntax = This.Object.DataWindow.Syntax
ll_syntax_len = Len( ls_syntax )
ll_index = 1
ls_target_object = "table"
ll_target_object_len = Len( ls_target_object )
ll_open_parenthesis = Pos( ls_syntax, ls_target_object + "(" ) +
ll_target_object_len
ls_test = Mid( ls_syntax, ll_open_parenthesis, 1 )
ll_index = 1
DO UNTIL ll_index = 0 OR ll_open_parenthesis = ll_syntax_len
ll_open_parenthesis++
ls_this_character = Mid( ls_syntax, ll_open_parenthesis, 1 )
IF ls_this_character = "(" THEN
ll_index ++
END IF
IF ls_this_character = ")" THEN
ll_index --
END IF
LOOP

IF ll_open_parenthesis < ll_syntax_len THEN
lds_temporary_storage = CREATE DataStore
lds_temporary_storage.Create( ls_syntax )
This.RowsCopy( 1, This.RowCount(), Primary!, lds_temporary_storage, 1,
Primary! )
// Put the Group information here.
ls_syntax_before = Left( ls_syntax, ll_open_parenthesis )
ls_syntax_after = Right( ls_syntax, ll_syntax_len -
ll_open_parenthesis )
ls_syntax_new = ls_syntax_before + '~r~ngroup(level=1 header.height=0
trailer.height=0 by=("' + is_object_name[ 1 ] + '" ) newpage=no
resetpagecount=no header.color="536870912" trailer.color="536870912" )' +
ls_syntax_after
This.Create( ls_syntax_new )
This.of_settransobject( sqlca )
lds_temporary_storage.RowsCopy( 1, lds_temporary_storage.RowCount(),
Primary!, This, 1, Primary! )
DESTROY lds_temporary_storage
This.Event ue_add_field_in_trailer()
ELSE
END IF

end if

ELSE
MessageBox( "Information", "Only columns in the main (detail) area can be
used when grouping. Please select a single column and try again." )
END IF
ELSE
ls_msg = ''
FOR ll_i = 1 TO UpperBound( is_object_name )
ls_msg += is_object_name[ ll_i ] + "~r~n"
NEXT
MessageBox( "Information", "Please make sure only one column is selected,
then try again.~r~nObjects selected:~r~n" + ls_msg )
END IF
//-------------------------------------------------------------------------/
/

is_object_name[] is an array of selected columns. ue_add_field_in_trailer()
pops up a window to add a computed column in the group trailer. You can
drop the inv_expression IF/THEN.

The basic concept is to cache the data, physically insert the group
information into the original DW syntax, recreate the DW, and reload the
data.

Ken Judkins

"Taufiq Ahmed" <taufi...@autosoftdynamics.com> wrote in message
news:4077a153@forums-1-dub...

Ken Drendel

unread,
Apr 13, 2004, 11:28:08 AM4/13/04
to
Or you could just create a group off a computed coulmn, and dynamically set the
computed columns expression to the column you want to group by. If there is no
group then leave the computed column expression = ''

Ken Drendel


On 13 Apr 2004 06:17:19 -0800,
in sybase.public.powerbuilder.datawindow

Ken Drendel

unread,
Apr 13, 2004, 11:38:36 AM4/13/04
to
Was this suppose to answer the "Re: Create group again " post?

Ken Drendel

On 13 Apr 2004 06:17:19 -0800,
in sybase.public.powerbuilder.datawindow
Ken Judkins <nos...@notime.not> wrote:

0 new messages