Custom HTML Form Items


This is something that gets brought up in a couple places
(example 1, example 2).

In DHTMLX Suite 5.0, you were able to make your own form controls. It would be great if version 7.0 could do so as well.

Perhaps a form item type called “custom” could be added, which would start out as an Input item, and the user could modify it via functions that are passed to the item.

Here is a proof of concept:
Add something similar to the following to the switch case statement in Form.prototype._addLayoutItem:

case "custom": {
	var Custom = /** @class */ (function (_super) {
		__extends(Custom, _super);
		function Custom() { return _super.apply(this, arguments); }
		if (config.changeElement != null) {
			Custom.prototype._draw = function () {
				const vNode =, ...arguments);
				vNode.onhydrate = () =>, vNode.el.querySelector("input"), config, vNode);
				return vNode;
		return Custom;

	var custom_1 = (this._attachments[name] = new Custom(null, config));
	this._state[name] = custom_1.getValue();, function (props) {
		return, [name, props]);
	});, function (props) {
		_this._changeProps(name, props);
		_this._state[name] = custom_1.getValue();, [name, props]);
	});, function (value) {
		_this._state[name] = value;, [name, value]);
	});, function (value, init) {
		if (!init) {
			return, [name, value]);
	});, function (value) {
		return, [name, value]);
	});, function (value, init) {
		!init &&, [name, value]);
	});, function (value) {
		_this.layout.getCell(name).show();, [name, value]);
	});, function (value) {
		return, [name, value]);
	});, function (value, isValid) {, [name, value, isValid]);

And then add something like this at the end of the if (vnode.el == null) block in the function hydrate:

if (vnode.onhydrate) {
    vnode.onhydrate(vnode, withEl);

Here’s an example Input using this to create a typeahead dropdown list:

var form = new dhx.Form("form_container", {
    rows: [
            type: "custom",
            id: rootKwargs.index,
            label: "State",
            value: "Alaska",
            changeElement: (element, config, vNode) => {
                states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
                $(element).typeahead({ hint: true, highlight: true, minLength: 1 }, { name: "states", source: function findMatches(query, callback) {
                    const matches = [];
                    const substrRegex = new RegExp(query, 'i');
                    $.each(states, function(i, str) { if (substrRegex.test(str)) { matches.push(str); } });
                } });



Thank you for your suggestion.
I’ve sent it to the dev team and it will be observed.