[article rbarticle] - Client-side SDK - rbf_getFieldContext

Posted by Mohammed Siraj on 17-Dec-2015 00:27

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.

All Replies

Posted by IramK on 17-Dec-2015 04:27

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

Posted by IramK on 17-Dec-2015 05:41

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

Posted by Chandrasekhar Gontla on 17-Dec-2015 06:21

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.

Posted by Mohammed Siraj on 17-Dec-2015 08:45

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);

Posted by Thierry Ciot on 18-Dec-2015 09:08

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 !

Posted by Thierry Ciot on 18-Dec-2015 11:40

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.

Posted by Mohammed Siraj on 22-Dec-2015 23:21

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.

Posted by IramK on 07-Jan-2016 04:01

Hello Siraj,

This would be available from 4.0.5. onwards?

Cheers.

Iram

Posted by Mohammed Siraj on 07-Jan-2016 04:20

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

This thread is closed