Pages

Showing posts with label Datawindow. Show all posts
Showing posts with label Datawindow. Show all posts

Wednesday, October 13, 2010

Modify Compute Field Expression in Powerbuilder

Compute Field is an object in Powerbuilder programming, which can be inserted in datawindow. One of mandatory property of Compute Field is Expression.

Expression is set of statement or syntax which represent what you want to show at this compute field. Can be static text, calculation, or the other things.

When you create a datawindow and insert a compute field object, you can set the expression visually. But some times, you want to change the expression statement dynamically, which mean the expression will change depending of condition. Let say, if one of condition is fulfilled, you want to show: OK in the compute field, otherwise is NO.

Let say, in a Datawindow named dw_1, we create 1 compute object named co_1. The default expression is if(kd_kategori=2,'OK','NO'). It's mean if kd_kategori's value is 2, then we want to show text: OK, otherwise is: NO.




But, in some condition you want to change the default expression into if(kd_kategori=200,'OK','NO'), let say if someone in STAFF level is accessing the application.



Then you must create a script like below:

IF userlevel='STAFF' THEN
   dw_1.object.co_1.expression = "if(kd_kategori=200,'OK','NO')"
ELSE
   dw_1.object.co_1.expression = "if(kd_kategori=2,'OK','NO')"
END IF
»»  READMORE...

Thursday, July 22, 2010

What is Datawindow?

Note: I'm the author of this article. I published 4 articles at http://allaboutpowerbuilder.blogspot.com a year ago, and some how I lost the log-in ID for the account :( So, I re-write the article in my new blog.

Datawindow Control is the heart of Powerbuilder. This is the control to communicate between the Database and the client user interface.

This is the BIGGEST different between Powerbuilder and the other programming languages. In Powerbuilder, programmers start to make application from the database into datawindow control, then visualize into the other controls (like Dropdown, Radio Button, etc), column per column. Later, you can setup the properties for each column, like display properties, validation properties, etc.

It's very contradiction with Visual Basic (VB) for example. In VB, we put the control (Dropdown for example) at the form, the we setup the properties, how to connect into the database, table and column name at the last.

Take a look the images below:


Datawindow Painter Toolbar





To create a new Datawindow control, choose the database source, then Presentation Style.











Setup what the Table(s) and column(s) you want to display. Also setup the data criteria(s) and "sort by" value(s).















Last, setup the properties for each column, such as display properties, format properties, validation properties, position, etc.
»»  READMORE...