Workaround to make DBCOMBO to work with numeric Item field

Workaround to make DBCOMBO to work with numeric Item field

Postby Milan Mehta » Wed Feb 22, 2006 6:57 am

Hello,

Is there any workaround to make DBCOMBO to work with numeric Item field ? We are in the process of converting legacy application into FWH. And almost all the applications has numeric primary key in the master table. I am heavily stuck up here.

Can anybody guide me ?

TIA
Milan.
Milan Mehta
 
Posts: 115
Joined: Mon Oct 17, 2005 4:42 am
Location: India


Postby James Bott » Wed Feb 22, 2006 7:45 am

Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Milan Mehta » Thu Feb 23, 2006 11:00 am

Dear James,

Do u mean to say that I should try to array browse with DBCOMBO ? Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).

Can u please guide further ?

TIA
Milan.


James Bott wrote:Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James
Milan Mehta
 
Posts: 115
Joined: Mon Oct 17, 2005 4:42 am
Location: India

Postby James Bott » Thu Feb 23, 2006 2:19 pm

Milan,

Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).


I see there is a bug in DBCombo when you try to pass the arrays in the definition like this:

@ 10,30 dbcombo oDBC var cItem of oDlg;
items aItems;
list aList

Instead do it like this:

@ 10,30 dbcombo oDBC var cItem of oDlg
oDBC:setItems( aItems, aList )

This is working for me.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 77 guests