PDA

View Full Version : Database column type char breaks combo item selection



mohaaron
24 Jun 2009, 12:35 PM
Hello All,

I've just found that when using a char(2) column type on my lookup table and a char(10) column type on the form table the combobox will not set the selected value. Is this a bug?

Example:
Form Value: "IT"
Combo Value "IT "

This will not work when the combo is bound to the form. Should this be fixed or what would be an appropriate solution?

aconran
24 Jun 2009, 5:45 PM
Could you please explain further and post some code so that we can assist you?

mohaaron
25 Jun 2009, 9:30 AM
This will take me a little while to build a complete example. I have started working on this though.

Really all you need to do is build a form that has a field which is a type combo. Have the combo read it's data in from a table that has char(2) as the PK and set the valueField as the PK column.

Then read in the forms data from a table that has a matching foreign key value but make the matching column a char(10).

The extra empty spaces on the char(10) column causes the values to not match when being compared in the setValue method. So even though the two columns may contain the same value the extra empty spaces from the char(10) column cause a mismatch.

I'll post a complete example once I get it done.

carol.ext
25 Jun 2009, 9:37 AM
How about trimming the spaces off the char(10) data when you load it? I wouldn't expect the combo to ignore the spaces.

mohaaron
25 Jun 2009, 9:46 AM
Yes that was my first thought when I found the problem. I just didn't know where in the js code to do this. I also figured that it was bad practice to have different PK and FK column signatures. So I changed the database fields to match and it fixed the problem. I'm just wondering if having a trim() in the ext setValue comparison would be appropriate or should it stay out of the code base and be an override or something.

Just so you know I'm not the most advanced javascript programmer so I don't know how best to do this.