Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

New TIBCO Community Coming Soon
In early summer, TIBCO plans to launch a new community—with a new user experience, enhanced search, and expanded capabilities for member engagement with answers and discussions! In advance of that, the current myibi community will be retired on April 30. We will continue to provide updates here on both the retirement of myibi and the new community launch.

What You Need to Know about Our New Community
We value the wealth of knowledge and engagement shared by community members and hope the new community will continue cultivating networking, knowledge sharing, and discussion.

During the transition period, from April 20th until the new community is launched this summer, myibi users should access the TIBCO WebFOCUS page to engage.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     MAINTAIN - ComboBox help!

Read-Only Read-Only Topic
Go
Search
Notify
Tools
MAINTAIN - ComboBox help!
 Login/Join
 
Platinum Member
posted
Okay, I'm struggling through a Maintain application -- the comboboxes are giving me fits as they just don't seem intuitive to me. But then again, sometimes I'm just dense...

I have a table that I want to update in a MS SQL Server database. The table has a couple of ID columns that are foreign keys to other tables. Naturally I want to populate that column with an ID, but want to provide the user with a combobox (dropdown) of the possible choices.

I've created the form and added the comboboxes. On the list source, I've picked "From a variable" and pointed it to a stack that represents the FK table. The column I've picked is the "name" column so the user sees the appropriate names in the combobox. In the bind the selection result, I picked the stack that represents the table I'm updating and picked the ID column from that stack that FKs to the other "name" table. I've also picked to send the result as "value".

Here's the dilemma, when I'm adding a new record, all seems to work fine. But when I want to update an existing record, the dropdown does not represent the current value of that record when the form opens. In other words, I could have picked the 4th value in the combobox, but when the form opens, it always shows the first item in the combobox. It will still update correctly, it's just that it doesn't show correctly upon opening of an existing record.

Forgive the frustration, but is there another "hoop" that I have to jump through now to make this select the existing value?



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
 
Posts: 230 | Location: Wichita, KS | Registered: May 27, 2005Report This Post
Virtuoso
posted Hide Post
The item you want to be highlighted/selected in the combo box needs to be set.


Unfortunately, there is no easy way around this.

Run a case that loops through the stack until the value in the field in the stack matches your required value, that is then the FocIndex to set.

Goes something like:

myStack.FocIndex= search(IncomingFieldValue);

Case search takes searchString/a12 returns Index/i6;
Declare cntr/i6=1;
Index=-1;
repeat myStack.FocCount
if (searchString eq myStack(cntr).searchField) then Index = cntr;
if index gt -1 goto exitrepeat;
endrepeat cntr=cntr+1;
EndCase

Hope that helps.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Platinum Member
posted Hide Post
Using your example, I think I got it working. Mine was a little different since I was actually searching for the ID in the stack, but the concept was the same.

I ended up having to code 3 different search functions because I had 3 different comboboxes (from 3 different stacks). My OOP brain makes me think there should be a way to do it in one function, but that would mean I had to pass the stackname and searchfield as parameters to the function also -- and I couldn't find any obvious datatypes for that...

If you have any suggestions, that would be great -- but I appear to be working again thanks to your help!

[rant]It really is unfortunate though to have to jump through that extra hoop just to make this happen though -- for something that seems as basic as a dropdown list[/rant]



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
 
Posts: 230 | Location: Wichita, KS | Registered: May 27, 2005Report This Post
Virtuoso
posted Hide Post
Glad it seems to be working for you.

There is no OOP way that I can find, so 3 different functions it is. My record is 10!

Wouldn't it be nice to say:

myStack.FocIndex = WHERE(myStack.fieldname EQ searchString);

There's one for sleepless nights and the maintain development team.

(Gregory Dorman tried to explain a 'why' to me years ago. I got lost after sentence 2.)


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Member
posted Hide Post
Trav,

I realize this was over a year ago, but do you mind posting your solution? I've run into the same issue and am struggling w/the proper syntax to locate the ID.

I agree there should be a much easier way to accomplish this common thing.

Thanks,


quote:
Originally posted by Trav:
Using your example, I think I got it working. Mine was a little different since I was actually searching for the ID in the stack, but the concept was the same.

I ended up having to code 3 different search functions because I had 3 different comboboxes (from 3 different stacks). My OOP brain makes me think there should be a way to do it in one function, but that would mean I had to pass the stackname and searchfield as parameters to the function also -- and I couldn't find any obvious datatypes for that...

If you have any suggestions, that would be great -- but I appear to be working again thanks to your help!


Kelly
WF 7.6.6, Win 2K3 SP2, Tomcat
 
Posts: 19 | Location: SLC, UT | Registered: January 19, 2007Report This Post
Master
posted Hide Post
Kelly
We had tried methods of setting the SelectedItem value to the desired selection, but that always seemed to break something else. The BEST way to preset a List or Combo box is with this code:

Compute I/I2=1;
Repeat ComboBoxStack2.Foccount
If ComboBoxStack2(I).field = ComboBoxStack1().field then Begin
Compute ComboBoxStack2.Focindex = I;
Goto ExitRepeat
Endbegin
Compute I=I+1;
Endrepeat

Here, ComboBoxStack1().field is the selection from the first box that determines what is displayed in the second. If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Member
posted Hide Post
Thank you, Mark. I was able to get it working great.

Much appreciated!



quote:
Originally posted by Maintain Wizard:
Kelly
We had tried methods of setting the SelectedItem value to the desired selection, but that always seemed to break something else. The BEST way to preset a List or Combo box is with this code:

Compute I/I2=1;
Repeat ComboBoxStack2.Foccount
If ComboBoxStack2(I).field = ComboBoxStack1().field then Begin
Compute ComboBoxStack2.Focindex = I;
Goto ExitRepeat
Endbegin
Compute I=I+1;
Endrepeat

Here, ComboBoxStack1().field is the selection from the first box that determines what is displayed in the second. If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.

Mark


Kelly
WF 7.6.6, Win 2K3 SP2, Tomcat
 
Posts: 19 | Location: SLC, UT | Registered: January 19, 2007Report This Post
Platinum Member
posted Hide Post
mark,

quote:
If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.



I like to use something like the following code to take care of that possibility:

Repeat While (I NE 0) I=stkCombo.Foccount;
Compute stkCombo.Focindex = I ;
If stkCombo(I).Field EQ stkDatabase().Field Then Goto Exitrepeat;
Endrepeat I=I-1;

In addition I make sure that I have a dummy item ( such as 'Unknown) as the first member/record in the stack. This way the validation Javascript can see if the user made a selection, and if the database doesn't match any of the values in the combo box stack, it displays a meaningful value, instead of the erroneous last item.

BTW What do you call stack rows ? Rows, records, items. elements ??
I tend to use 'item', but not sure if I'm communicating well...


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server
 
Posts: 165 | Location: Detroit Metro | Registered: September 17, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     MAINTAIN - ComboBox help!

Copyright © 1996-2020 Information Builders