Alpha DevCon 2018
Results 1 to 7 of 7

Thread: FormView Data API Changes to the settings object

  1. #1
    Alpha Software Employee Beta Spark's Avatar
    Real Name
    Sarah Mitchell
    Join Date
    Jul 2015
    Posts
    388

    Default FormView Data API Changes to the settings object

    Recent changes to the FormView Control's API have been made to simplify passing data to Editors. FormView settings are now encapsulated inside the settings.formView namespace. This helps to reduce conflicts between user-defined settings and system settings. This change affects the settings['*a5column'] and settings.data objects.

    Using settings.formView.active.path

    Before, when getting the name of the field being updated to set a title, you could use settings['*a5column'] to fetch the field's name:
    Code:
    var title = settings['*a5column'];
    var eleTitle = $('EDITOR_2.FIELDLABEL');
    eleTitle.innerHTML = title;
    With the recent API change, you should use settings.formView.active.path instead:
    Code:
    var title = settings.formView.active.path;
    var eleTitle = $('EDITOR_2.FIELDLABEL');
    eleTitle.innerHTML = title;
    Using settings.formView.active.target

    Supported in Alpha Anywhere builds released on or after 12/21/2016:

    For Group Editors, settings['*a5column'] was previously used to determine what field was selected so focus could be set to a specify control in the Group Editor. Unfortunately, you cannot use settings.formView.active.path to determine the selected field. settings.formView.active.path will be an array containing all of the fields that are assigned the Group Editor for editing.

    To get the field that was clicked when the Group Editor was activated, use settings.formView.active.target. For example:

    Code:
    var control = settings.formView.active.target;
    control = 'EDITOR_3_' + control;
    var ele = {dialog.object}.getPointer(control);
    ele.select();
    Using settings.formView.data

    In the "Cascading Dropdownbox Editors" video demonstration, the settings.data object is used to determine what value to filter the City dropdown box by looking up the value of the State field. This is the code from the "Set value in editor":
    Code:
    if(settings['fieldName'] == 'State') { 
    	var choices = getStates();
    } else if(settings['fieldName'] == 'City') { 
    	var state = settings.data.State;
    	choices = getCities(state);
    }
    
    if(typeof choices != 'undefined') { 
    	{dialog.object}.populateDropdownBox('EDITOR_2_TXTBOX',choices,true);
    }
    
    
    {dialog.object}.setValue('EDITOR_2_TXTBOX',value);
    With the new changes, this block of code becomes the following:
    Code:
    if(settings['fieldName'] == 'State') { 
    	var choices = getStates();
    } else if(settings['fieldName'] == 'City') { 
    	var state = settings.formView.data.State;
    	choices = getCities(state);
    }
    
    if(typeof choices != 'undefined') { 
    	{dialog.object}.populateDropdownBox('EDITOR_2_TXTBOX',choices,true);
    }
    
    
    {dialog.object}.setValue('EDITOR_2_TXTBOX',value);
    Existing UX components that use the FormView control are unaffected, however when building new Editors, you should use the new syntax.

    This change to the FormView settings object was originally posted in the Pre-Release Notes.

    Additional Resources

    To learn more about the FormView control and Editors and Editor Sets, checkout the resources listed below:

    The Basics

    Creating Editors

    Other Types of Editors
    • Switch Editors: Discover how you can use an in-line switch to edit values instead of an editor set for binary and multi-value fields.
    • FormView Image Capture: Learn how easy it is to capture images using the FormView control
    Last edited by Beta Spark; 12-20-2016 at 12:51 PM.
    Sarah Mitchell

    Looking for answers? Try our documentation.
    If you can't find something, let us know!

  2. #2
    Member
    Real Name
    Bruce Rainwater
    Join Date
    Sep 2005
    Posts
    174

    Default Re: FormView Data API Changes to the settings object

    When the editor is using fields in a group
    settings.formView.active.path returns a string of all the fields in the group
    settings["*a5column"]; returns undefined

    how can I get the name of the field that was clicked on the form to open the editor ?
    Bruce Rainwater

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

    Default Re: FormView Data API Changes to the settings object

    Bruce, I'm sure there's a better way to do this... but... this isnt' too bad. It's a bit of a workaround. I can't see anything in the settings object that specifies the control you clicked on to display the group editor.

    However... get into the FormView. For each Field in the Group... fill in the Property "Field title in editor" with the exact name of the field. E.g. If you have a field name Qty... enter Qty... or QTY as a Field Title.

    Because we're in a group, the Textbox for Qty in the Group... let's say EDITOR_3_QTY... can have a Field Label... e.g. Quantity... so we're not message anything up.

    Now... in the Editor, Show Editor event... you can do this...

    var control = settings.title;
    control = 'EDITOR_3_' + control;
    var ele = {dialog.object}.getPointer(control);
    ele.select();

    settings.title holds the title of the field you clicked on... and now the balance of the code can continue.

  4. #4
    Member
    Real Name
    Bruce Rainwater
    Join Date
    Sep 2005
    Posts
    174

    Default Re: FormView Data API Changes to the settings object

    Thanks, after a lot of looking I came up with the same solution last night, it actually works pretty well because I can also use the title on the editor also
    sometimes the simplest solution is the best
    thanks for the response
    Bruce Rainwater

  5. #5
    Alpha Software Employee Beta Spark's Avatar
    Real Name
    Sarah Mitchell
    Join Date
    Jul 2015
    Posts
    388

    Default Re: FormView Data API Changes to the settings object

    Quote Originally Posted by brainwater View Post
    When the editor is using fields in a group
    settings.formView.active.path returns a string of all the fields in the group
    settings["*a5column"]; returns undefined

    how can I get the name of the field that was clicked on the form to open the editor ?
    Hello Bruce,

    This is an excellent question. If the editor set is a Group editor, the settings.formView.active.path is an array. I can't find anything in the formView object that indicates what field was selected.

    I have passed this on to the dev team and they're looking into it.

    Thanks!
    Sarah Mitchell

    Looking for answers? Try our documentation.
    If you can't find something, let us know!

  6. #6
    Alpha Software Employee Beta Spark's Avatar
    Real Name
    Sarah Mitchell
    Join Date
    Jul 2015
    Posts
    388

    Default Re: FormView Data API Changes to the settings object

    Hello Bruce,

    In tomorrow's pre-release build (and future releases), you can get the selected field for a group editor as follows:
    Code:
    var control = settings.formView.active.target;
    control = 'EDITOR_3_' + control;
    var ele = {dialog.object}.getPointer(control);
    ele.select();
    Sarah Mitchell

    Looking for answers? Try our documentation.
    If you can't find something, let us know!

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

    Default Re: FormView Data API Changes to the settings object

    Excellent... thanks.

Similar Threads

  1. Saving FormView Control Data to a SQL Database
    By Beta Spark in forum Tablet-Optimized Form Capabilities Beta
    Replies: 3
    Last Post: 03-24-2017, 12:42 PM
  2. FormView CSS Namespace
    By Beta Spark in forum Tablet-Optimized Form Capabilities Beta
    Replies: 0
    Last Post: 10-30-2015, 02:23 PM
  3. ViewBox and FormView progress
    By edsicard in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 02-07-2015, 02:57 PM
  4. Browse Property and Object Explorer settings both fail
    By rmcgaffic in forum Alpha Five Version 9 - Desktop Applications
    Replies: 6
    Last Post: 07-22-2008, 09:47 AM
  5. View, Settings, Data Entry dialog
    By davej in forum Alpha Five Version 5
    Replies: 5
    Last Post: 10-01-2003, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •