Results 1 to 5 of 5

Thread: F2 lookup

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Location
    Dubai, United Arab Emirates
    Posts
    485

    F2 lookup

    I think the following feature would be very nice to have as a standard Lianja textbox type control.

    I have two tables Customers and order

    In the orders form I want to show the company name from customers, without having to add a section for customers on the page.

    Text control placed on form from Orders which has it's data source as field from Orders which is the the FK (foreign key) from Customers

    Set attributes in control for:

    Name of table to pull the value from. This would be empty by default and the system uses the table for the FK, in this case Customers.
    Or we could have a value, in VFP this is a view but in Lianja would be the Lianja equivalent

    Field(s) from customers to be displayed. This could be for example cCustomerName or alltrim(cCustomerName) + ', ' + alltrim(cCustomerTown)

    Name of form to use for adding new entry and editing existing one. This is brought up by right clicking on the control, or via a Key press, currently F2 in my framework, but could be set via an attribute, with default value pre filled.

    This control auto fills, so if the the field to display was CCustomerName and I have the following customer names:

    Big Company 1
    Big Company 2
    Small company

    If I enter B the control brings up a list of the two companies that have name beginning with B

    if I enter S it auto fills with Small company since this is the only entry I have for the letter S

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,963
    Quote Originally Posted by avianmanagement View Post
    I think the following feature would be very nice to have as a standard Lianja textbox type control.

    I have two tables Customers and order

    In the orders form I want to show the company name from customers, without having to add a section for customers on the page.

    Text control placed on form from Orders which has it's data source as field from Orders which is the the FK (foreign key) from Customers

    Set attributes in control for:

    Name of table to pull the value from. This would be empty by default and the system uses the table for the FK, in this case Customers.
    Or we could have a value, in VFP this is a view but in Lianja would be the Lianja equivalent

    Field(s) from customers to be displayed. This could be for example cCustomerName or alltrim(cCustomerName) + ', ' + alltrim(cCustomerTown)

    Name of form to use for adding new entry and editing existing one. This is brought up by right clicking on the control, or via a Key press, currently F2 in my framework, but could be set via an attribute, with default value pre filled.

    This control auto fills, so if the the field to display was CCustomerName and I have the following customer names:

    Big Company 1
    Big Company 2
    Small company

    If I enter B the control brings up a list of the two companies that have name beginning with B

    if I enter S it auto fills with Small company since this is the only entry I have for the letter S
    The new autosuggest feature in Beta11 will handle this, with a little bit of subclassing.

    Dropping in subclassed controls visually won't come until V1.1 (the last time I looked at the roadmap). Until then, you'll use the regular control, and then we can substitute the subclass using an extension (I think -- haven't tried it yet).

    OTOH, an FK Display Table, FK Picklist Table, and FK Display Description options on the autosuggest would be nice. The Display Table (remember, virtual views count here) shows all entries (important when displaying entries that are not pickable, but still need to be shown). The Picklist Table (defaults to the Display Table) shows the valid pick options.

    Hank

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,963
    Hi,

    I'm replying to a new post on this thread from Rob Calhoun, for which I received an email notification but can't see here on the forum.

    Here's the question:

    *******

    Hank,

    I'm interested in your response to this query as we have a large number of FK linked code tables in our system which use the F2 lookup approach which is a standard feature of the Visual MaxFrame framework on which our legacy system is built.

    I've read through the AutoSuggestion and Choices docs and I think I understand how you can build dynamic lists based on the contents of a specified table and field, or by using a sql statement to populate the list which can then include multiple columns of which one is designated as the search column.

    However, these all seem designed to update a bound field with the user's selection as it is displayed. I'm not clear on how this would work in the case where the bound field is an FK and we want to update the bound field with the FK of the users selection.

    Is it possible to specify hidden column in the sql which wound't be displayed but could be bound to the field? Something similar to how we use the standard VFP combo box which allows binding to any column in the list.


    Cheers,

    Rob

    *************
    And now my reply:

    Hi Rob,

    In the desktop FK lookups are handled through datamapping, using the field (control) Get data mapping and Set data mapping delegates. These are detailed in the docs and present in the desktop example apps where applicable. Easy Peasy.

    The same (but different) will be available in V5.0 (the next version after the current which is nearing the end of the beta, based on features already present in the Roadmap), according to the roadmap.

    And yes, there is a way to make it work in mobile even now, a little more elegantly than adding another field (that's where I started when doing a POC a year ago or so on this -- by using the Change delegate to make the change on the backend, etc.), but I would wait until V5.0 to do it the right way.

    Good question (what business app doesn't a) use surrogate keys and b) do FK lookups?), and the elegant solution for web/mobile is close at-hand.

    Hank





  4. #4
    Member
    Join Date
    Sep 2013
    Location
    Bristol UK
    Posts
    95
    Hank,

    Sorry about that. I apparently deleted my previous message while editing it!

    So, just to make sure I'm understanding you ....

    I have an FK field in the table holds the foreign key to a code/description in another table
    The section would include a Code textbox/combo configured with choices or autosuggestion to allow the user to specify one of a restricted list of codes.
    The section would also include a R/O description textbox to display the full name of the code. I believe I could use a textbox with an expression data source here.
    On selection of a code, the code textbox change delegate would update the back end FK field and the code description textbox assuming it is not based on an expression.

    I assume this approach would also require some code in the Data Changed delegate to initialise the code and description fields during navigation and additions?

    Would this approach work for both inline and full page edits? I assume so but never hurts to verify.

    Cheers,

    Rob

  5. #5
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,963
    Hi Rob,

    For desktop, no code is required other than the settings in Get data mapping and Set data mappin.

    For web/mobile, V5.0 will do it the elegant way. As with software in general, there is always a way and usually many ways to get here from there. FWIW, my experiment was in a Grid, but would have worked in a formitem (which can display as a combo).

    Hank

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us