Problem for two fieldtypes
Problem for two fieldtypes
hykl
Posts: 48Questions: 19Answers: 5
I try for create two fieldtypes for 2 variables:
Examples - https://editor.datatables.net/examples/simple/fieldTypes.html
There is one fieldtype - To do or Done.
But I want to create two fieldtypes, how?
Source code - it does not WORK :(
Please you help :-)
(function ($, DataTable) {
if (!DataTable.ext.editorFields) {
DataTable.ext.editorFields = {};
}
var Editor = DataTable.Editor;
var _fieldTypes_1 = DataTable.ext.editorFields;
_fieldTypes_1.variable1 = {
create: function (conf) {
var that = this;
conf._enabled = true;
conf._input = $(
'<div id="'+Editor.safeId( conf.id )+'">'+
'<button class="inputButton" value="1">YES</button>'+
'<button class="inputButton" value="0">NO</button>'+
'</div>');
$('button.inputButton', conf._input).click( function () {
if (conf._enabled) {
that.set(conf.name, $(this).attr('value'));
}
return false;
});
return conf._input;
},
get: function (conf) {
return $('button.selected', conf._input).attr('value');
},
set: function (conf, val) {
$('button.selected', conf._input).removeClass('selected');
$('button.inputButton[value='+val+']', conf._input).addClass('selected');
},
enable: function (conf) {
conf._enabled = true;
$(conf._input).removeClass('disabled');
},
disable: function (conf) {
conf._enabled = false;
$(conf._input).addClass('disabled');
}
};
})
(jQuery, jQuery.fn.dataTable);
(function ($, DataTable) {
if (!DataTable.ext.editorFields) {
DataTable.ext.editorFields = {};
}
var Editor = DataTable.Editor;
var _fieldTypes_2= DataTable.ext.editorFields;
_fieldTypes_2.variable2 = {
create: function (conf) {
var that = this;
conf._enabled = true;
conf._input = $(
'<div id="'+Editor.safeId( conf.id )+'">'+
'<button class="inputButton" value="1">INSTALL</button>'+
'<button class="inputButton" value="0">NO INSTALL</button>'+
'</div>');
$('button.inputButton', conf._input).click( function () {
if (conf._enabled) {
that.set(conf.name, $(this).attr('value'));
}
return false;
});
return conf._input;
},
get: function (conf) {
return $('button.selected', conf._input).attr('value');
},
set: function (conf, val) {
$('button.selected', conf._input).removeClass('selected');
$('button.inputButton[value='+val+']', conf._input).addClass('selected');
},
enable: function (conf) {
conf._enabled = true;
$(conf._input).removeClass('disabled');
},
disable: function (conf) {
conf._enabled = false;
$(conf._input).addClass('disabled');
}
};
})
(jQuery, jQuery.fn.dataTable);
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This is resolved :-)
Thank you.