Skip to main content

Input

The Input control displays a field where users can enter text.

Toolbar input field with a type to search placeholder and a search icon in DHTMLX Suite

Related sample: Toolbar. Input

Add Input​

The following example adds an Input control to a toolbar with the add() method of TreeCollection:

toolbar.data.add({
type:"input",
value:"",
placeholder:"Type to search"
});

Properties​

Check the list of properties that you can set in the configuration object of an Input control.

Show and hide Input​

The show() and hide() methods of Toolbar show and hide an Input control by its ID:

toolbar.show(id);
toolbar.hide(id);

Related sample: Toolbar. Hide / show items

Enable and disable Input​

The enable() and disable() methods of Toolbar enable and disable an Input control by its ID:

toolbar.enable(id);
toolbar.disable(id);

Related sample: Toolbar. Enable / disable items

Add a tooltip​

Use the tooltip property to add a tooltip to an Input control:

{
type: "input",
value: "",
tooltip:"Type to search"
}

Related sample: Toolbar. Tooltips

Set and get the Input value​

Use the setState() and getState() methods of Toolbar to set and get the value of an Input control.

To fill an Input control with text, pass a key-value pair to the setState() method. The key is the ID of the input, and the value is the text:

{
type: "input",
id:"search",
value: ""
}
...
toolbar.setState({search:"Summer"});

To get the current text of an Input control, call the getState() method:

toolbar.getState(); //-> {search:"Summer"}

Set focus on a control​

The setFocus() method sets focus on an Input control. The method takes the ID of the control as a parameter:

toolbar.setFocus("search");
info

Check the full list of available operations in the Toolbar API and the TreeCollection API.