Skip to content
Open
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
32 changes: 20 additions & 12 deletions js/dataTables.cellEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ jQuery.fn.dataTable.Api.register('MakeCellsEditable()', function (settings) {

var cell = table.cell(this).node();
var oldValue = table.cell(this).data();
// Sanitize value
oldValue = sanitizeCellValue(oldValue);

// Show input
if (!$(cell).find('input').length && !$(cell).find('select').length) {
// Input CSS
var input = getInputHtml(currentColumnIndex, settings, oldValue);
$(cell).html(input.html);
if (input.focus) {
$('#ejbeatycelledit').focus();
//make computed field not editable
if(!isComputedValue(oldValue)){
// Sanitize value
oldValue = sanitizeCellValue(oldValue);

// Show input
if (!$(cell).find('input').length && !$(cell).find('select').length) {
// Input CSS
var input = getInputHtml(currentColumnIndex, settings, oldValue);
$(cell).html(input.html);
if (input.focus) {
$('#ejbeatycelledit').focus();
}
}
}
}
Expand All @@ -129,7 +132,7 @@ function getInputHtml(currentColumnIndex, settings, oldValue) {

if(settings.inputTypes){
$.each(settings.inputTypes, function (index, setting) {
if (setting.column == currentColumnIndex) {
if (setting.column === currentColumnIndex) {
inputSetting = setting;
inputType = inputSetting.type.toLowerCase();
}
Expand Down Expand Up @@ -162,7 +165,7 @@ function getInputHtml(currentColumnIndex, settings, oldValue) {
case "datepicker": //Both datepicker options work best when confirming the values
case "datepicker-confirm":
// Makesure jQuery UI is loaded on the page
if (typeof jQuery.ui == 'undefined') {
if (typeof jQuery.ui === 'undefined') {
alert("jQuery UI is required for the DatePicker control but it is not loaded on the page!");
break;
}
Expand Down Expand Up @@ -227,3 +230,8 @@ function sanitizeCellValue(cellValue) {
}
return cellValue;
}

function isComputedValue(cellValue) {
if (cellValue === null) { return false;}
return ( (typeof cellValue === 'function') || (typeof cellValue === 'object') );
}