Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,16 @@ Here are all the available options:
<td>If <code>true</code>, remove all Edit Properties buttons from objects.</td>
<td><code>false</code></td>
</tr>
<tr>
<tr>
<td>array_controls_top</td>
<td>If <code>true</code>, array controls (add, delete etc) will be displayed at top of list.</td>
<td><code>false</code></td>
</tr>
<tr>
<td>table_controls_left</td>
<td>If <code>true</code>, table controls (add, delete etc) will be displayed at left of list.</td>
<td><code>false</code></td>
</tr>
<tr>
<td>form_name_root</td>
<td>The first part of the `name` attribute of form inputs in the editor. An full example name is `root[person][name]` where "root" is the form_name_root.</td>
Expand Down Expand Up @@ -1251,6 +1255,7 @@ Editors can accept options which alter the behavior in some way.
* `disable_edit_json` - If set to true, the Edit JSON button will be hidden (works for objects)
* `disable_properties` - If set to true, the Edit Properties button will be hidden (works for objects)
* `array_controls_top` - If set to true, array controls (add, delete etc) will be displayed at top of list (works for arrays)
* `table_controls_left` - If set to true, table controls (add, delete etc) will be displayed at left of list (works for tables)
* `enum` - See [Enum options](#enum-options)
* `enum_titles` - An array of display values to use for select box options in the same order as defined with the `enum` keyword. Works with schema using enum values.
* `expand_height` - If set to true, the input will auto expand/contract to fit the content. Works best with textareas.
Expand Down
1 change: 1 addition & 0 deletions docs/imask.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
JSONEditor.defaults.options["disable_array_delete"] = 0;
JSONEditor.defaults.options["enable_array_copy"] = 0;
JSONEditor.defaults.options["array_controls_top"] = 0;
JSONEditor.defaults.options["table_controls_left"] = 0;
JSONEditor.defaults.options["disable_array_delete_all_rows"] = 0;
JSONEditor.defaults.options["disable_array_delete_last_row"] = 0;
JSONEditor.defaults.options["prompt_before_delete"] = 1;
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h2>Options</h2>
<option value='disable_array_delete'>Disable array delete buttons</option>
<option value='enable_array_copy'>Add copy buttons to arrays</option>
<option value='array_controls_top'>Array controls will be displayed at top of list</option>
<option value='table_controls_left'>Table controls will be displayed at left of list</option>
<option value='disable_array_delete_all_rows'>Disable array delete all rows buttons</option>
<option value='disable_array_delete_last_row'>Disable array delete last row buttons</option>
</select>
Expand Down
14 changes: 12 additions & 2 deletions src/editors/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class TableEditor extends ArrayEditor {
this.item_has_child_editors = itemSchema.properties || itemSchema.items
this.width = 12
this.array_controls_top = this.options.array_controls_top || this.jsoneditor.options.array_controls_top
this.table_controls_left = this.options.table_controls_left || this.jsoneditor.options.table_controls_left
super.preBuild()
}

Expand Down Expand Up @@ -104,7 +105,11 @@ export class TableEditor extends ArrayEditor {
this.controls_header_cell = this.theme.getTableHeaderCell(this.translate('table_controls'))
this.controls_header_cell.setAttribute('aria-hidden', 'true')
this.controls_header_cell.style.visibility = 'hidden'
this.header_row.appendChild(this.controls_header_cell)
if (this.table_controls_left) {
this.header_row.insertBefore(this.controls_header_cell, this.header_row.firstChild)
} else {
this.header_row.appendChild(this.controls_header_cell)
}

/* Add controls */
this.addControls()
Expand Down Expand Up @@ -148,7 +153,12 @@ export class TableEditor extends ArrayEditor {
ret.build()
ret.postBuild()

ret.controls_cell = row.appendChild(this.theme.getTableCell())
if (this.table_controls_left) {
ret.controls_cell = this.theme.getTableCell()
row.insertBefore(ret.controls_cell, row.firstChild)
} else {
ret.controls_cell = row.appendChild(this.theme.getTableCell())
}
ret.row = row
ret.table_controls = this.theme.getButtonHolder()
ret.controls_cell.appendChild(ret.table_controls)
Expand Down
1 change: 1 addition & 0 deletions tests/pages/_demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h2>Options</h2>
<option value='disable_array_delete'>Disable array delete buttons</option>
<option value='enable_array_copy'>Add copy buttons to arrays</option>
<option value='array_controls_top'>Array controls will be displayed at top of list</option>
<option value='table_controls_left'>Table controls will be displayed at left of list</option>
<option value='disable_array_delete_all_rows'>Disable array delete all rows buttons</option>
<option value='disable_array_delete_last_row'>Disable array delete last row buttons</option>
</select>
Expand Down
Loading