Sectioned Table Extension¶
All Sectioned Table extension classes must extend the IView
interface.
The return value of the view()
method must be a subclass of a native view (i.e. a subclass of UIView
for iOS or android.view.View
for Android) for section/table and form cell extensions. The viewIsNative()
must also be overridden to return true
.
Example¶
// file: MyExtensionView.ts
import * as app from 'tns-core-modules/application';
import { Color } from 'tns-core-modules/color';
import { IView } from 'mdk-core/IView';
export class MyExtensionView extends IView {
private _label: any;
private _value: any;
public initialize(props) {
super.initialize(props);
const color = new Color('yellow');
if (this.definition().data.ExtensionProperties.Prop1) {
this._value = this.definition().data.ExtensionProperties.Prop1.Value;
}
else {
this._value = "Default Value";
}
if (app.ios) {
this._label = UILabel.alloc().init();
this._label.numberOfLines = 3;
this._label.backgroundColor = color.ios;
} else {
this._label = new android.widget.TextView(this.androidContext());
this._label.setBackgroundColor(color.android);
}
}
public view() {
//Use provided ValueResolver to resolve value to support bindings, rules, etc in your extension
this.valueResolver().resolveValue(this._value).then((resolvedValue)=> {
if (app.ios) {
this._label.text = resolvedValue;
} else {
this._label.setText(resolvedValue);
}
});
return this._label;
}
public viewIsNative() {
return true;
}
}
Last update: August 12, 2020