[article rbarticle] - Client-side SDK - rbf_getFieldContext() - Forum - Rollbase - Progress Community

[article rbarticle] - Client-side SDK - rbf_getFieldContext()

 Forum

[article rbarticle] - Client-side SDK - rbf_getFieldContext()

  • For each field in an Object Record form (New/Edit/Status-Change/QuickCreate page), users can now acccess a FieldContext object using client-side API function rbf_getFieldContext(fieldIntegrationName).

    Eg: var fieldContext = rbf_getFieldContext('fieldA');

    This field context object will encapsulate state & behavior details for the given field.

    FieldContext object interface details:

    State:

    getNode(): Will return jquery object for the HTML control (input,select,textarea etc.).

    This will execute faster when compared to running a jquery selector (eg. $("input[name='textA']")) against the complete page DOM, as the jquery node reference is part of FieldContext object state.

    getKendoConfig(): Will return kendo configuration object for this field (only if the field is a kendo control).

    This function should be preferred to access kendo configuration object for a field, instead of $("input[name='feildA']").data('kendoDropdownList').

    It will execute faster as the kendo configuration object is part of field context state.

    Also, it does not impose any requirement on User to have knowledge of the specific kendo control type i.e. kendoNumericTextbox or kendoDropdownList or kendoMultiSelect.

    There will also not be any compatibility issues across releases if user comes through these Rollbase provided wrapper API's instead of directly working against the page DOM.

    getFieldType(): Will return a string identifier for the field type i.e. 'IntInput' for all Integer fields & similar.

    getFormNode(): Will return jquery node reference for the form element in page DOM.

    getContainer(): Will return jquery object for the root container element that holds this field control & all related DOM elements like validation <span>.

    Behavior:

    validate(): Will run client-side validations against the field.

    enable(isEnabled): Toggle functionality to enable/disable a field.

    show(): Will show the field.

    hide(): Will hide the field.

    focus(): Will give focus to the field.

    isRequiredField(): Will return boolean TRUE if the field is marked as a 'required' form field.

    getValue(): Will return the field's current value.

    setValue(value): Will set the field's value as per the passed argument.

    /** Following interface methods are available from Rollbase 4.0.5 onwards */

    addOnChangeHandler(handlerFunc): Will add a change handler for the field. 

    getInitialValue(): Will return the initial value of this form field when the form page was rendered. 

    hasValueChanged(): Will return Boolean TRUE if the field value was edited & modified in the form page.

    Additionally, for specific field types, we have additional interface methods as part of the field context object eg. setPicklistCode for Picklist fields. Will share them individually as specific to each field type. 

    Note: This API is specific to New UI pages.

    Regards,
    Siraj.
  • Hello Siraj,

    Thanks for the above post. Is there a specific place in the forum where we can track these articles? Kindly let me know.

    Cheers.

    Iram

  • Hello @Siraj,

    Also along these lines of using rbf_getFieldContext(), what is the best way of getting the selected picklist item's code? I know I can get the value of the picklist item by: rbf_getFieldContext().getValue(). Is there a way to get the code of the selected item?

    Cheers.

    Iram

  • Hi Iram,

    I published a white paper called "Rollbase New UI - Customization" in community.

    It includes various customization that can be applied in Rollbase New UI.

    It describes the rbf_getFieldContext() method as well.

    You can find the pdf in the below thread.

    community.progress.com/.../2696

    Thanks and Regards,

    Chandu.

  • Iram, for now field context object for Picklist field does not have a getPicklistCode API. Will add this going forward.

    At present, you can use rbf_getPicklistCode(fieldIntegrationName);

    Regards,
    Siraj.
  • We are using the convention to prefix the post with [article] in the subject.

    We don't have other mechanism, though we should try to remember to also add article as a tag !

  • I just realized that search for [article] is not that great so decided to change the convention and use [article rbarticle] in subject (and also add tags) like in this post: community.progress.com/.../21085

    I'll ask each article author to update the subject so that we can quickly and uniquely find them.

    Thierry.

  • As requested earlier, we have added fieldContext.getPicklistCode API for the following fields:

    Picklist

    MultiPicklist

    RadioButtons

    CheckBoxGroup (already existed)

    Also rbf_getPicklistCode(fieldIntegrationName) global function has been re-implmented to delegate to this new API. This should resolve all outstanding issues with rbf_getPicklistCode global function.

    Regards,
    Siraj.
  • Hello Siraj,

    This would be available from 4.0.5. onwards?

    Cheers.

    Iram

  • Yes Iram, the above set of fixes have been committed to 4.0.5 release branch.

    Regards,
    Siraj.