Customizations

ZPM.Net can be customized by overriding method prototypes. Additionally there are built in extension methods that make the job easy. Below are examples of how to overriding method prototypes and use the built in extension methods.

We are available for customizations to the framework or to help with application development.
Use the Contact Us page to reach us.

DataView Supporting Additional Data Types And Custom Controls

Here's an example of how to support a data type not supported by the DataView class. First pick a name for the data type. We'll use 'bool2' as the name. DataView already supports bool, so bool2 would be redundent in practice.

In CustomerView.cshtml, change data-type="bool" to data-type="bool2":

<tr>
    <td class="zpm-dv-td-prompt">Monthly Statements</td>
    <td><div style="width:80px"><input id="Statement" type="checkbox" class="df-getset" data-type="bool2" /></div></td>
</tr>
Note the <div> around the checkbox control. Checkboxes require special handling in Dataview. The background color of a checkbox cannot be changed, so in order to show a yellow background when the user checks or unchecks the checkbox, DataView will change the background color of the checkbox's parent. In this case the background color of the div will be changed.

Add this code to CustomerView.cshtml, in the ready function:
dv.GetSetCustomFunctionAssign = function ($ctrl, dataType, getset) {
    switch (dataType) {
        case "bool2": // checkbox
            if ($ctrl[0].nodeName == 'INPUT' && $ctrl.prop('type') == 'checkbox') {
                $ctrl[0].DataView_SetData = function (value) { this.checked = value; };
                if (getset)
                    $ctrl[0].DataView_GetData = function (onBlur) { return this.checked; };
            } else {
                throw "invalid nodeName '" + $ctrl[0].nodeName + "' for data type bool on control id '" + $ctrl[0].id + "'";
            }
            break;
        default:
            throw "invalid data type: " + dataType + " on control id '" + $ctrl[0].id + "'";
    }
};
This will override the GetSetCustomFunctionAssign method. To support more data types, just add another case statement. The parameter getset is false if this is a read-only field that will be set, but will not have it's value read.

DataView_SetData is assigned a function that will set the value of the control. It could be a simple assignment, like this, or the control could be a div with multiple controls that are affected by value.

DataView_GetData is assigned a function that will get the value from the control. The parameter onBlur is true if the user is leaving the data field. Use this to redisplay formatted data. See ZpmDataView.prototype.Get_NumericUsingVal() for an example of this.