Skip to content

Commit

Permalink
[add] a section on editing columns with type:number into grid/treegri…
Browse files Browse the repository at this point in the history
…d guides
  • Loading branch information
mafanya23 committed Oct 18, 2023
1 parent 32b18bd commit 95004fc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
Binary file added docs/assets/grid/col_number_validation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions docs/grid/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,37 @@ There is a list of [configuration settings](grid/api/api_gridcolumn_properties.m
}
~~~

### Editing columns with the "number" type

For columns with the **type:"number"** setting the **editorConfig** object may contain additional properties, besides the [common ones](grid/api/api_gridcolumn_properties.md#editorconfig). They are:

- **min** - (optional) the minimum allowed value
- **max** - (optional) the maximum allowed value

~~~js
const grid = new dhx.Grid("grid", {
columns: [
{
id: "col1",
width: 180,
type: "number",
editorConfig: { min: 5, max: 100 },
},
// more columns
]
});
~~~

In case a user enters a value that goes beyond the limits specified by the above settings, the entered value is highlighted in red:

![Validation of columns with the number type](../assets/grid/col_number_validation.png)

If the user ignores the warning and still tries to enter an unallowable value, it will be replaced with the minimum/maximum value defined in the **editorConfig** object by the **min/max** values. Thus, in the above example the entered value `200` will be replaced with `100`, since it is the upper limit set in the editor configuration.

:::note
In the <b>autoHeight:true</b> mode columns with the <b>type:"number"</b> must have the editor with the <b>"input"</b> type, unless a different editor type is specified.
:::

### Editable combobox

From v7.3, you may allow end users to add new options into the combobox editor ([editorType: "combobox"](#types-of-column-editor)) from UI. To activate the functionality, specify the **newOptions: true** attribute of the **editorConfig** property in the configuration of the [column](grid/api/api_gridcolumn_properties.md):
Expand Down
2 changes: 1 addition & 1 deletion docs/treegrid/api/api_treegridcolumn_properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ columns:[
<ul>
<li><b>selectAllButton</b> - (optional) adds a button that allows selecting all the options in the editor</li>
</ul><br>
If the <b>type: "date"</b> is specified for a column, the <b>editorConfig</b> object can include <a href="https://docs.dhtmlx.com/suite/category/calendar-properties/">a set of properties of Calendar</a> (except for the <b>value</b>, <b>range</b>, and <b>dateFormat</b> ones).<br>
If the <b>type: "date"</b> is specified for a column, the <b>editorConfig</b> object can include <a href="https://docs.dhtmlx.com/suite/category/calendar-properties/">a set of properties of Calendar</a> (except for the <b>value</b>, <b>range</b>, and <b>dateFormat</b> ones).<br><br>
If the <b>type:"number"</b> is specified, the <b>editorConfig</b> object can include two more properties:
<ul>
<li><b>min</b> - (optional) the minimum allowed value</li>
Expand Down
31 changes: 31 additions & 0 deletions docs/treegrid/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,37 @@ There is a list of [configuration settings](treegrid/api/api_treegridcolumn_prop
}
~~~

### Editing columns with the "number" type

For columns with the **type:"number"** setting the **editorConfig** object may contain additional properties, besides the [common ones](treegrid/api/api_treegridcolumn_properties.md#editorconfig). They are:

- **min** - (optional) the minimum allowed value
- **max** - (optional) the maximum allowed value

~~~js
const treegrid = new dhx.TreeGrid("treegrid", {
columns: [
{
id: "col1",
width: 180,
type: "number",
editorConfig: { min: 5, max: 100 },
},
// more columns
]
});
~~~

In case a user enters a value that goes beyond the limits specified by the above settings, the entered value is highlighted in red:

![Validation of columns with the number type](../assets/grid/col_number_validation.png)

If the user ignores the warning and still tries to enter an unallowable value, it will be replaced with the minimum/maximum value defined in the **editorConfig** object by the **min/max** values. Thus, in the above example the entered value `200` will be replaced with `100`, since it is the upper limit set in the editor configuration.

:::note
In the <b>autoHeight:true</b> mode columns with the <b>type:"number"</b> must have the editor with the <b>"input"</b> type, unless a different editor type is specified.
:::

### Editable combobox

From v7.3, you may allow end users to add new options into the combobox editor ([editorType: "combobox"](#types-of-column-editor)) from UI. To activate the functionality, specify the **newOptions: true** attribute of the **editorConfig** property in the configuration of the [column](treegrid/api/api_treegridcolumn_properties.md):
Expand Down

0 comments on commit 95004fc

Please sign in to comment.