1. Mayank Chauhan
  2. PowerBuilder
  3. Saturday, 6 May 2023 20:30 PM UTC

I have 3 column with the name country_id , states_id and city_id in a datawindow with dropdown datawindow style in powerbuilder.
I'm using below code in itemchange event but when re select country then states and city column show country row id and state row id.

 

this.accepttext( )
long ll_country_id, ll_state_id,ll_city_id
DATAWINDOWCHILD ldwc_state, ldwc_city, ldwc_country

this.getchild('country_id',ldwc_country)
this.getchild('state_id',ldwc_state)
this.getchild('city_id',ldwc_city)

if dwo.name = 'country_id' then
	ldwc_state.reset()
	ldwc_city.reset( )
	this.setitem(this.getrow(),'state_id', ' ' )
	this.setitem(this.getrow(),'city_id',  ' ' )
	ldwc_country.accepttext( )
	ll_country_id = ldwc_country.getitemnumber(ldwc_country.getrow(),'country_id')
	ldwc_state.settransobject(sqlca)
	ldwc_state.accepttext( )	
	ldwc_state.retrieve(ll_country_id)
end if

if dwo.name = 'state_id' then
	ldwc_city.reset( )
	this.setitem(this.getrow(),'city_id',  ' ' )
	ll_country_id = ldwc_country.getitemnumber(ldwc_country.getrow(),'country_id')
	ll_state_id = ldwc_state.getitemnumber(ldwc_state.getrow(),'state_id')
	ldwc_city.settransobject(sqlca)
	ldwc_city.accepttext( )
	ldwc_city.retrieve(ll_state_id,ll_country_id)
end if





Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 7 May 2023 12:36 PM UTC
  2. PowerBuilder
  3. # 1

Hi,

Don't do AcceptText() withing ItemChanged.

State_id and City_id, are they number or string type fields?

Itemchanged has arguments ROW and DATA, check out the help.

Something like this maybe:

long ll_country_id, ll_state_id,ll_city_id, ll_null
DATAWINDOWCHILD ldwc_state, ldwc_city, ldwc_country

this.getchild('country_id',ldwc_country)
this.getchild('state_id',ldwc_state)
this.getchild('city_id',ldwc_city)
setnull(ll_null)

if dwo.name = 'country_id' then
	ldwc_state.reset()
	ldwc_city.reset()
	
	// Question: are state_id and city_id string or number values?
	//this.setitem(ROW,'state_id', ' ' )
	//this.setitem(ROW,'city_id',  ' ' )
	// I'm assuming they are numeric values:
	this.setitem(ROW,'state_id', ll_null )
	this.setitem(ROW,'city_id',  ll_null )
	
	if isnumber(data) then
		ll_country_id = Long(DATA)
		ldwc_state.settransobject(sqlca)
		ldwc_state.retrieve(ll_country_id)
	end if
end if

if dwo.name = 'state_id' then
	ldwc_city.reset( )
	// Question: is city_id a string or numeric value?
	//this.setitem(this.getrow(),'city_id',  ' ' )
	// I'm assuming it's a numeric value:
	this.setitem(ROW, 'city_id',  ll_null )
	
	ll_country_id = This.getitemnumber(ROW, 'country_id')
	if isnumber(data) then
		ll_state_id = Long(DATA)
		ldwc_city.settransobject(sqlca)
		if not isnull(ll_country_id) and not isnull(ll_state_id) then
			ldwc_city.retrieve(ll_state_id, ll_country_id)
		end if
	end if
end if
Comment
  1. Mayank Chauhan
  2. Sunday, 7 May 2023 18:22 PM UTC
Thanks
  1. Helpful
  1. Marcelo Peñailillo
  2. Tuesday, 15 October 2024 16:39 PM UTC
I confirm this anomalous behavior. In no DatawindowChild the row with the field value is selected. In previous versions of Appeon PowerBuilder it correctly selected the corresponding row. Does anyone know how we can request the correction of this Bug? This post is from a year ago
  1. Helpful
  1. David Peace (Powersoft)
  2. Friday, 18 October 2024 10:56 AM UTC
I'm not sure what bug you are referring to? The problem above was a coding issue that was answered. I suggest you raise a new request for help with you problem and example code and we will help.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.