The Portal Connector MVC API

This section contains documentation related to The Portal Connector MVC client-side API which can be used to leverage existing widget functionality. This version of the API makes use of the Kendo UI API (More information on that can be found here).

Working with the API

In order to begin working with the API in the first place, you will have to retrieve widgets to work with! There are a number of ways to retrieve widgets, including using the indexed form, the name of the form, and the find/findAll methods. Below you will find information on all the methods available within the TPC API.


tpc.forms

Returns an array of all TPC Form Objects on the page. The TPC Form Object provides access to all TPC Form Widgets within the TPC Form.

EXAMPLE-GET TPC FORMS

//Returns all TPC Form Objects tpc.forms; //Returns the first TPC Form Object in the Array tpc.forms[0]; //Returns the TPC Form Object that belongs to the form named "formtest" tpc.forms.formtest;

EXAMPLE-ACCESS FORM WIDGET

//Returns the TPCTextField Object within the first TPC Form Object tpc.forms[0].firstname;
Parameters

None

Returns

Array of TPC Form Objects


tpc.findAll()

Returns an array of all TPC Form Widgets on the page.

EXAMPLE-GET ALL TPC FORM WIDGETS

//Returns all TPC Form Widgets tpc.findAll();
Parameters

None

Returns

Array of TPC Form Widget Objects


tpc.find()

Returns a TPC Form Widget Object specified by name. (Which is typically the attribute that the widget has been configured to use)

EXAMPLE-GET TPC FORM WIDGET BY NAME

//Returns the TpcBoolean Object for the Widget named "donotphone" tpc.find("donotphone");
Parameters

String: The name of the widget object

Returns

TPC Form Widget Object


tpc.isFormValid()

Returns a Boolean that indicates whether the specified TPC Form is valid or invalid.

EXAMPLE-IS FORM VALID

/*Returns a Boolean indicating whether or not the "formtest" TPC Form is valid or invalid based on the current data. */ tpc.isFormValid("formtest"); /*Returns a Boolean indicating whether or not the "formtest" TPC Form is valid or invalid based on the current data, after an additional Kendo Validation has been triggered.*/ tpc.isFormValid("formtest", true);
Parameters

String: The name of the TPC Form Object

Boolean: Indicates whether or not to re-trigger the forms Kendo Validation (Optional)

Returns

Boolean: Indicating whether or not the form is valid (true) or invalid (false)


tpc.isFieldDirty()

Returns a Boolean that indicates whether the specified field within a TPC Form has been changed or is the original value that was first loaded.

EXAMPLE-IS FIELD DIRTY

//Returns a Boolean indicating whether or not the "firstname" field within the "formtest" TPC Form is dirty. tpc.isFieldDirty("firstname", "formtest"); //Returns a Boolean indicating whether or not the first "firstname" field found on any TPC Form is dirty. tpc.isFieldDirty("firstname");
Parameters

String: The name of the TPC Form Field

String: The name of the TPC Form Object that contains the field (Optional)

Returns

Boolean: Indicating whether or not the field is dirty (true) or clean (false)


tpc.getDirtyFields()

Returns an Array of information containing all dirty fields within the specified TPC Form(s).

EXAMPLE-DIRTY FIELDS

//Return an Array of all the dirty fields on the page var allDirtyFields = tpc.getDirtyFields(); //Dirty Field Information var fieldName = allDirtyFields[0].field; var formName = allDirtyFields[0].form; var newValue = allDirtyFields[0].new; var oldValue = allDirtyFields[0].old; var tpcFormWidget = allDirtyFields[0].obj; //Returns an Array of all dirty fields within the TPC Form named formtest tpc.getDirtyFields("formtest");
Parameters

String: The name of the TPC Form Object (Optional)

Returns

Array of Dirty Field Information


(Event) tpc:ready

This event is triggered once all of the TPC Page and Form Widgets on a page have been initialized.

EXAMPLE-TPC:READY

//Listen for tpc:ready Event $(document).on("tpc:ready", function(event, tpcObject){ console.log("All TPC Widgets have been Initialized"); console.log(event); //tpc:ready Event console.log(tpcObject); //TPC Window Object });
Parameters

Function: The function to be executed once the tpc:ready event is triggered

Returns

Event: tpc:ready Event

Object: tpc Window Object