Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extended editor capabilities #509

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Standard placeholder is defined by colname
LukasK13 committed Feb 25, 2018
commit aad86fb584ff2cf0653196393d5302c78191761a
14 changes: 7 additions & 7 deletions inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
@@ -696,7 +696,7 @@ HTMLWidgets.widget({
} else {
table.columns().every(function() {
if (this.header().innerHTML != ' ')
$(this.header()).attr('data-editortype', 'text').attr('data-editoroptions', JSON.stringify({placeholder: ''})); // set column editor attributes
$(this.header()).attr('data-editortype', 'text').attr('data-editoroptions', JSON.stringify({placeholder: this.header().innerHTML})); // set column editor attributes
});
}

@@ -708,11 +708,11 @@ HTMLWidgets.widget({
if (table.column(this).header().getAttribute('data-editortype') == 'text') { // cell shall display a textinput
var $input = $('<input type="text">');
$input.val(value);
$input.attr("placeholder", JSON.parse(table.column(this).header().getAttribute("data-editoroptions")).placeholder);
$input.attr('placeholder', JSON.parse(table.column(this).header().getAttribute('data-editoroptions')).placeholder);
} else if (table.column(this).header().getAttribute('data-editortype') == 'select') { // cell shall display a selectinput
var $input = $('<select>');
$(JSON.parse(table.column(this).header().getAttribute("data-editoroptions")).options).each(function(index, val) {
$option = $("<option>").attr('value', val).text(val);
$(JSON.parse(table.column(this).header().getAttribute('data-editoroptions')).options).each(function(index, val) {
$option = $('<option>').attr('value', val).text(val);
if (val == value) $option.attr('selected','selected');
$input.append($option);
});
@@ -744,10 +744,10 @@ HTMLWidgets.widget({
do {
column = column.nextSibling;
}
while (column !== null && !column.hasAttribute("data-editortype"));
while (column !== null && !column.hasAttribute('data-editortype'));
if (column === null) { // a editable column was not found after the current column, search before the current column
column = table.column(0).header();
while (!column.hasAttribute("data-editortype"))
while (!column.hasAttribute('data-editortype'))
column = column.nextSibling;
}
var nextColNumber = $(column).parent().children().index(column); // calculate the index of the next editable column
@@ -758,7 +758,7 @@ HTMLWidgets.widget({
if (HTMLWidgets.shinyMode) editorNextCell = [table.cell($this).index().row, nextColNumber]; // save next cell to be clicked after a possible table reload by the server
} else { // next column is in the following row
// find next row in the current ordering, pagination and search
var rows = table.rows({order: "current", page: "current", search: "applied"}).indexes();
var rows = table.rows({order: 'current', page: 'current', search: 'applied'}).indexes();
var i = 0;
while (i < rows.length && rows[i] != table.cell($this).index().row)
i++;