Alpha DevCon 2018
Results 1 to 18 of 18

Thread: OFFLINE: Lookup field value in another UX list control with edit combo box

  1. #1
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default OFFLINE: Lookup field value in another UX list control with edit combo box

    Hi,

    I have multiple list controls in my offline ux.
    "List1", "List2" & "List3"

    "List1" has no "records" whilst in offline and i want to capture a new record.
    "List3" was pre-populated from my sql database BEFORE the app went offline. Records are available in detail view whilst offline.

    I need to create a edit combo box lookup from field A in "List1" to field A in the data source "List3"

    "List3" will be the data source for "list1" if and when an edit combo box for a field is defined.

    How do i configure edit combo box in the detail view of "List1" to lookup the values from the source "List3"?

    Your assistance will be appreciated

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Do you have to use an text control configured as an edit combo box?

    If you could use a DropdownBox control, then you could populate it with a Javascript function which would grab data from List3. I'm not sure if an edit combo box can do that.

    Basically... all you want to do is use List3 as the source of a dropdown control while building a new record for List1... is that right?

  3. #3
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Quote Originally Posted by Davidk View Post
    Do you have to use an text control configured as an edit combo box?

    If you could use a DropdownBox control, then you could populate it with a Javascript function which would grab data from List3. I'm not sure if an edit combo box can do that.

    Basically... all you want to do is use List3 as the source of a dropdown control while building a new record for List1... is that right?
    Dave,

    Correct, drop down box will suffice. I just want to use List3 as the source for List1 new record data.

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Attached is a UX showing how to populate a DropdownBox control from a List control. I've used static data in the Lists but that shouldn't matter... I'm just getting data from a loaded List. You'll need to change the names of the object properties used in the code. My test List3 is State names and abbreviates... which you'll see in the code.

    The DropdownBox control starts out with an empty row which I've added... and the .populateDropdownBox() method does not clear this out. The code which populates the dropdown is...

    Code:
    var lObj = {dialog.Object}.getControl('LIST3');
    var lData = lObj._data;
    var stateData = lData.map(function(a){
     	return [a.StateName,a.StateAbbr];
    });
    {dialog.Object}.populateDropdownBox('State',stateData,false);
    ux_List1_Dropdown_List3.a5wcmp

  5. #5
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Dave

    It does exactly what i needed. It keeps the "downloaded" choices and adds the "new" records captured during the offline status. Great stuff.

    Question;
    How do you propose i "lookup and fill" the rest of the field based on the offline dropdown box. Do i do it in the same code you provided?

    List1 fields = SiteName (dropdown box, List3 as source), Address (Auto fill with SiteAddress), ContactName (Auto fill with SiteContactName)
    List3 fields = SiteName (offline source), SiteAddress, SiteContactName

  6. #6
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Since the DropdownBox control can hold only 2 columns of data, you'll need to back to List3 to get more data. So, you might as well get the key for List3 from the dropdown and the balance of the data from List3... which means loading the dropdown with just 1 column of data.

    The code is below and a UX is attached which now mimics your columns... but I have to ask why use a List control as a data source? Just curious. Is this anything to do with the Lookup Fields features just added to Alpha? Is this a PhoneGap Build app? Does List3 do anything more than provide data for List1?

    Code to populate the dropdown...

    Code:
    var lObj = {dialog.Object}.getControl('LIST3');
    var lData = lObj._data;
    var siteData = lData.map(function(a){
     	return [a.SiteName];
    });
    {dialog.Object}.populateDropdownBox('SiteName',siteData,false);
    onChange event of the dropdown. Lots of ways to get this data... this is just one way...

    Code:
    var list3Key = this.value;
    var lObj = {dialog.object}.getControl('LIST3');
    var siteAddress = lObj.getData(this.value).SiteAddress;
    var siteContactName = lObj.getData(this.value).SiteContactName;
    {dialog.Object}.setValue('SiteAddress',siteAddress);
    {dialog.Object}.setValue('SiteContactName',siteContactName);
    You'll note in the attached UX that the DropdownBox control is configured is bit differently. There is no static data entered... no pipe... since it's just one column populating this control now.

    The onChange event of the dropdown gets the value selected and then goes after List3 for the balance of the data.
    ux_List1_Dropdown_List3.a5wcmp

  7. #7
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Hi David,

    My client has requested a true offline app whereby field workers can "download" specific data from sql on their laptops. this data should then be persisted on the laptop for up to a week at a time without any communication to the sql db. Once a week they will sync back to the server.

    The strategy here is;
    Create a UX with a list representing the sql tables required for field workers to capture what they need whilst still complying to certain validations i.e. "no duplicate clients" etc.

    the client can also at any time "update" or change data in one of these tables. by doing this they will request field workers to only refresh this table from the server and not everything.

    The above is working great thus far and my only challenges is;
    1 - Once the list is populated from sql and the field worker goes offline, the list becomes the source for all fields [List3 = Client table]
    2 - A second list becomes the source for a series of "cascading with explicit filtering" [List4 = Substrates]. This became problematic due to the "auto" population of field data/options. A call back is required once a field value is required on an explicit filtering method. Cascading lists does not [in my experience] pre-populate these field options.
    3 - In the app a client is "captured" with some specific requirements captured as part of the client site visit. These fields obtain their values from the other "lists".

    ALL of this happens whilst there is NO callback to the server.

    I hope i made sense in the above, but the logic is the following;
    By using the UX component with Lists controls, i don't need to create localised sql dbs and backend sql sync procedures with i.e. sync framework etc. The maintenance and admin overheads would be just to great as this will be utilised by about 340 people in the field.

  8. #8
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Sorry David, i forgot to answer your question;

    The app has 6 lists of which only 2 of them are used during the capture period. The other 4 are ONLY source of field data to these 2 lists.

    Lists in app;
    List 1 = Client capturing / information
    List 2 = Specification capturing / Information
    List 3 = Substrates Information [only a source of information to List 2 using explicit filtering on cascading controls] multiple fields
    List 4 = Primer Information [only a source of information to list 2 using explicit filtering on cascading controls] 1 field only
    List 5 = TopCoat Information [only a source of information to list 2 using explicit filtering on cascading controls] 2 field only
    List 6 = Waterproof information [only a source of information to list 2 using explicit filtering on cascading controls] 1 field only

    The client list is the 1st list appearing in the app followed by a cascading "specifications" list. You require a client before you can capture the specification for that client.

  9. #9
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    David,

    I'm most probably being daft, but i can't seem to get your "fill" code to work on mine. The only difference between them as i see, is the source field name is different than the populate field.

    you're code

    debugger;
    var list3Key = this.value;
    var lObj = {dialog.object}.getControl('LIST3');
    var siteAddress = lObj.getData(this.value).SiteAddress;
    var siteContactName = lObj.getData(this.value).SiteContactName;
    {dialog.Object}.setValue('SiteAddress',siteAddress);
    {dialog.Object}.setValue('SiteContactName',siteContactName);

    My code

    debugger;
    var ClientKey = this.value;
    var lObj = {dialog.object}.getControl('CLIENT');
    var clientcontact = lObj.getData(this.value).ContactName;
    var clientofftel = lObj.getData(this.value).ContactOffTel;
    {dialog.Object}.setValue('clientcontact',clientcontact);
    {dialog.Object}.setValue('clientofftel',clientofftel);

    I attached my ux for you to see
    Attached Files Attached Files

  10. #10
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Your CLIENT list is set to return the PrimaryKey... which is ClientID. So, the code to load your DropdownBox control would have to be changed to...

    Code:
    return [a.BusinessName,a.ClientID];
    Now... "this.value" will be the ClientID... which is the key into the CLIENT List control.

    You don't need "var ClientKey = this.value;"... it's not being used. I forgot to delete it from my code.

    If this is a PhoneGap Build app I wouldn't use List controls as data sources. I'd use a SQLite database stored on the device... or store the data you need in the local filesystem. There are several methods available for storing data other than using a List control. The List control is great, but as a data store it's a bit heavy.

    What version/build of Alpha are you using?

  11. #11
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Thanks Dave, I actually thought "this.value" reads the value chosen in the dropdown box as the key value.
    I will test and provide you with feedback

  12. #12
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Dave,

    It's not a phonegap app. I'm using the UX and offline capabilities for a desktop app. It does actually work well, especially if i use the HTML page function to start the app without the sql connection. There is little niggles that is beyond me, but i'm trying to resolve them as they pop up.

    Do you propose another way this can be hosted on localised devices [laptops/desktops]?

  13. #13
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Quote Originally Posted by CLaubscher View Post
    Thanks Dave, I actually thought "this.value" reads the value chosen in the dropdown box as the key value.
    I will test and provide you with feedback
    Yes... that's right... in the onChange event of the DropdownBox, this.value is the selection made by the user. That value is then used to get the appropriate row from the List. We're actually using this.value throughout the code instead of assigning it to a variable.

  14. #14
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Dave,

    Attached is my UX (OfflineFill) with the the 2 relevant lists. It just does not work and I've searched the message board for answers / examples. I saw a few where you explained exactly the same.

    Does it NOT make a difference if my list data is actually SQL data and yours static.
    Attached Files Attached Files

  15. #15
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Your DropdownBox control onChange event code is wrong. You have...

    Code:
    debugger;
    //var list3Key = this.value;
    var listObj = {dialog.object}.getControl('LIST1');
    var ClientContact = listObj.getData(ClientID).ContactName;
    var ClientOffTel = listObj.getData(ClientID).ContactOffTel;
    {dialog.Object}.setValue('clientcontact',ClientContact);
    {dialog.Object}.setValue('clientofftel',ClientOffTel);
    ,
    Where ClientID is not defined... and you have an extra comma at the end of the code.

    The code should be...

    Code:
    var listObj = {dialog.object}.getControl('LIST1');
    var ClientContact = listObj.getData(this.value).ContactName;
    var ClientOffTel = listObj.getData(this.value).ContactOffTel;
    {dialog.Object}.setValue('clientcontact',ClientContact);
    {dialog.Object}.setValue('clientofftel',ClientOffTel);
    and... you don't have the Return value type property set in LIST1. Set that to PrimaryKey... and all is good. Attached is your corrected, working UX. In some cases there may be a difference between working with Static Data and SQL Data. In this instance there is no difference.

    Dropdown_Fill.a5wcmp

  16. #16
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Hi Dave,

    A million thank yous to you. It does indeed work. It seems at the end my UX had some issues. I recreated a new UX and carried all the lists over. Done.

    One issue i did indeed pick up was [see attachment]

    When i create a new record, the Client ID replaces the actual BusinessName. You said it only returns 2 columns. How do i return column 1 and not 2.
    Attached Images Attached Images

  17. #17
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,733

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    I'd suggest you use the DropdownBox control as a non-databound control... as a pure data selector... maybe named ddClientId. Remove it from the list detail setup. Then just get the BusinessName along with the other data you want. The onChange code would be...

    Code:
    var listObj = {dialog.object}.getControl('LIST1');
    var ClientContact = listObj.getData(this.value).ContactName;
    var ClientOffTel = listObj.getData(this.value).ContactOffTel;
    var BusinessName = listObj.getData(this.value).BusinessName;
    {dialog.Object}.setValue('clientcontact',ClientContact);
    {dialog.Object}.setValue('clientofftel',ClientOffTel);
    {dialog.Object}.setValue('businessname',BusinessName);
    The nature of the DropdownBox control is to have a Display Value and a Selected Value. Unless you don't want to display a Business Name in the dropdown... just a number.

  18. #18
    Member CLaubscher's Avatar
    Real Name
    Corn
    Join Date
    Oct 2016
    Posts
    15

    Default Re: OFFLINE: Lookup field value in another UX list control with edit combo box

    Works like a charm and i'm using same all over the app now. Your time was wasted with great effect and success. Thanks for that.

    Question
    My original problem description indicated issues with "explicit" cascading dropdown boxes. Now they work great as normal, BUT, i have 2 fields that requires cascading from the same parent dropdown. Is there some manual javascript i can use for this secondary dropdown as it gets disabled or rather does not display any value once the parent is already used?

Similar Threads

  1. Edit-Combo List Lookup Watermark
    By BCJack in forum Mobile & Browser Applications
    Replies: 4
    Last Post: 02-28-2015, 10:17 PM
  2. Edit-Combo list lookup
    By trickytrees in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 01-30-2015, 11:59 PM
  3. Edit Combo List lookup Display Format of logical field
    By jennygong in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 12-19-2014, 02:03 PM
  4. Filter isue with Lookup- Edit-Combo List
    By davtech in forum Application Server Version 11 - Web/Browser Applications
    Replies: 2
    Last Post: 02-22-2013, 02:06 PM
  5. Web - Grid - Lookup - Edit Combo-List
    By rnoguera in forum Archived Wishlist
    Replies: 0
    Last Post: 11-25-2010, 09:28 AM

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
  •