Link to home
Create AccountLog in
Avatar of tesmc
tesmcFlag for United States of America

asked on

Setting cursor on a dropdown datawindow to point to latest entry

I created a datawindow with 2 child datawindow (drop down datawindows).
The child datawindows are drop downs which a user can select from a list.
One of the options on the list of both drop down dw are <Add New>.
In my itemchanged() i have the following :
However when user selects <add new> and enters/saves the new entry from w_div_detail then goes back to main dw -
that drop down datawindow gets reset & does not scroll/setfocus to the newly created item on the list for display.
Even when i click another button it resets to <add new> which is at position 0 and doesn't scroll to latest addition.
i tried setfocus, find, scrolltorow. etc. nothing works.
Please help me move the position on the drop down datawindow to point to new entry the user just created.
CHOOSE CASE GetColumnName()
		
CASE	"divid"
 
if idwc_divid.getitemstring( idwc_divid.getrow() , "divdesc") = '<Add New>' then
 
	openwithparm( w_div_detail, 'D')
	if gl_divid <> 0 then
		idwc_divid.retrieve()
		this.setitem( row, "divid", gl_divid)
	end if
end if	
 
ll_divid = long(data) 
ll_subid = dw_div_master.getitemnumber( row, 'subid') 
 
if (data ='' or isnull(data) ) then 
	messagebox( '', 'Div is not populated.', stopsign!)
	return 1
end if
 
END CHOOSE

Open in new window

Avatar of diasroshan
diasroshan
Flag of Kuwait image

modify your code as below......
In below line from script, I assumed that 'divid' is the column name in drop down datawindow. Change it with the exact name you have.....

ll_find = idwc_divid.Find("divid="+gl_divid,1,idw_divid.rowcount())


Regards,
Sandeep
CHOOSE CASE GetColumnName()
		
CASE	"divid"
 
if idwc_divid.getitemstring( idwc_divid.getrow() , "divdesc") = '<Add New>' then
 
	openwithparm( w_div_detail, 'D')
	if gl_divid <> 0 then
		idwc_divid.retrieve()
                  //set focus to new record on dddw - start
                  long ll_find
                  ll_find = idwc_divid.Find("divid="+gl_divid,1,idw_divid.rowcount())
                  if ll_find > 0 then
                       idwc_divid.SetRow(ll_find)
                       idwc_divid.ScrollToRow(ll_find)
                   end if
                  //set focus to new record on dddw - end
 
		this.setitem( row, "divid", gl_divid)
	end if
end if	
 
ll_divid = long(data) 
ll_subid = dw_div_master.getitemnumber( row, 'subid') 
 
if (data ='' or isnull(data) ) then 
	messagebox( '', 'Div is not populated.', stopsign!)
	return 1
end if
 
END CHOOSE

Open in new window

Avatar of tesmc

ASKER

i was able to find the answer on my own. thx
Thats good....Can we know in brief what idea you have implemented?

Regards,
Sandeep
ASKER CERTIFIED SOLUTION
Avatar of tesmc
tesmc
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account