Ropardo Sowftware development company

Experience software development with ROPARDO S.R.L.

RSS Feed
RSS Feed
  • Home
  • About ROPARDO S.R.L
  • Our websites

Populate DDDW based on the value of another DDDW

The contents of a particular drop down datawindow depends on the value of another drop down datawindow.
For example we need to filter some employees based on the team they belong to. In the current datawindow, Teams will be a drop down datawindow whose contents depend on the value of another DDDW - Departments.

Will assume the datasource of the datawindow containing the two dddws, named t_filter, contains team_id and department_id columns having the generic value of 0 (where the id in both teams and departments tables start with 1).
We create two datawindows with following datasources and link properly to each dddw:

SELECT departments.id AS department_id,
departments.description AS department_description FROM departments
UNION (SELECT 0 AS department_id, '-' AS department_description FROM t_filter LIMIT 1)
SELECT teams.id AS team_id,
         teams.department_id AS department_id,
         teams.description AS team_description
	FROM teams
		WHERE teams.description_id = :adepartment_id
	UNION
	(SELECT 0 AS team_id,
		0 AS department_id,
        '-' AS team_description FROM t_filter LIMIT 1)

The rest of the code will be in the filter window.
We declare a datawindowchild as instance variable. The department variable will hold the last department selection to avoid unnecessary database traffic.

DataWindowChild dwc;
int department;

When the datawindow is retrieved will have to avoid the retrieval argument request, right before the main retrieve call, in the Open() event (dw_main is the container datawindow control placed in the filter window):

CONNECT USING SQLCA;
dw_main.SetTransObject(SQLCA);
dw_main.GetChild("team_id", dwc);
dwc.InsertRow(0);
dw_main.InsertRow(0);
dwc.SetTransObject(SQLCA);
dw_main.Retrieve();

If the user selects a different department, the content of the teams dddw child will have to be updated. In the ItemChanged event:

if GetColumnName() = "department_id" then
	int val;
	val = Integer(this.GetText());
	if val != department then
	        department = val;
		dwc.Retrieve(val);
	end if
</code>end if

The problem so far is that if the teams drop down gets filtered and the user has previously selected a value which will be out of filter range, the drop down will still display the old id value. Will avoid this issue extending the pbm_dwndropdown and pbm_ncpaint events.

event ue_dropdown;
if GetColumnName() = "department_id" then
	dw_main.SetRedraw(false);
	dw_main.SetColumn("team_id");
	dw_main.SetText("-");
	dw_main.SetColumn("department_id");
	dw_main.SetRedraw(true);
end if
 
event ue_ncpaint;
dwc.Retrieve(this.object.data[1, nDepartmentsColIndex]);
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Get Shareaholic
Tags: datawindow dropdowndatawindow filter powerbuilder Sybase

 Posted in: Power Builder
October 5, 2009 | Daniel Bozdoc | No Comments

Leave a Reply

 


  • « Previous post
  • Next post »
  • Recent Posts

    • Installing PyGraphviz on Windows
    • Convert python object to XML representation
    • Liferay Portlet Development
    • Norway Road Show 2011 private meeting invitation
    • Oracle OpenWorld 2011
  • Ropardo is Hiring

  • Subscribe

    • Add to Google Reader or Homepage Add to netvibes TopOfBlogs
  • Recent Comments

    • Rajkumar Pomaji on Bluetooth PC Remote Control
    • Stelian Morariu on GWT 2.1 – Uploading a file using the RPC mechanism
    • Sergio on GWT 2.1 – Uploading a file using the RPC mechanism
    • Artem on Liferay: Deployment will start in a few seconds… and how to realy start
    • rkd80 on GWT 2.1 – Uploading a file using the RPC mechanism
  • Archives

    • November 2011 (1)
    • September 2011 (4)
    • July 2011 (3)
    • June 2011 (2)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (3)
    • February 2011 (2)
    • January 2011 (2)
    • December 2010 (1)
    • November 2010 (4)
    • October 2010 (4)
    • August 2010 (3)
    • July 2010 (3)
    • June 2010 (6)
    • May 2010 (8)
    • April 2010 (7)
    • March 2010 (9)
    • February 2010 (6)
    • January 2010 (5)
    • December 2009 (7)
    • November 2009 (9)
    • October 2009 (10)
    • September 2009 (14)
    • August 2009 (10)
    • July 2009 (1)
    • June 2009 (1)
    • May 2009 (1)
    • April 2009 (1)
    • March 2009 (1)
    • October 2008 (3)
    • October 2007 (3)
    • July 2007 (4)
    • June 2007 (1)
    • May 2007 (3)
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • News (15)
    • Ropardo Team (8)
    • Ropardo Products (6)
      • File Tracking Client (4)
      • iManagement (2)
    • Software Development (83)
      • Microsoft.NET (22)
      • Java (40)
      • Oracle (8)
      • Power Builder (3)
      • Liferay (5)
      • Lotus Notes (9)
      • xWiki (4)
    • System Adminstration (13)
      • Linux (10)
      • Windows (3)
    • Programming (1)
    • Uncategorized (3)
    • Databases (10)
      • MSSQL (5)
      • PostgreeSQL (3)
    • Microsoft.NET (1)
    • Web Development (28)
      • ASP/ASPX (3)
      • Content Management Systems (1)
      • HTML/CSS (5)
      • Javascrip/AJAX (8)
      • PHP (7)
    • Oracle E Business Suite (6)
  • Tags

    .NET ajax blog C# certification client CMS control css database Debugging django Domino Eclipse extension file tracking filter fun gentoo google Hibernate how to html image iManagement import Java javascript jQuery liferay Linux Lotus Notes lotus script Oracle Oracle BI Publisher 11g PHP portal PostgreSQL powerbuilder Python SQL Telerik velocity xml Xwiki

© 2010 ROPARDO s.r.l..

Powered by WordPress. Styled by Ropardo