Select2
Select2
Hi,
I tried to use the plug-in called select2 but I obtained an error.
Can you told me what I wrong?
Thank you very much
(function($){
$(document).ready(function() {
var Editor = new $.fn.dataTable.Editor( {
"ajax": "php/table.masterdata.php",
"table": "#masterdata",
"fields": [
{
"label": "ID",
"name": "ID",
"type": "text"
},
{
"label": "CUSTOMER",
"name": "CUSTOMER",
"type": "select2",
"ipOpts": [
{
"label": "a",
"value": "a"
},
{
"label": "b",
"value": "b"
},
]
}
]
} );
$('#masterdata').dataTable( {
"dom": "Tfrtip",
"ajax": "php/table.masterdata.php",
"columns": [
{
"data": "ID"
},
{
"data": "CUSTOMER"
}
],
"tableTools": {
"sRowSelect": "os",
"aButtons": [
{ "sExtends": "editor_create", "Editor": Editor },
{ "sExtends": "editor_edit", "Editor": Editor },
{ "sExtends": "editor_remove", "Editor": Editor }
]
}
} );
} );
}(jQuery));
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
What error?
ups.
I forgot the error during the copy/paste procedure.
I'm sorry.
Chrome told me "Uncaught TypeError: undefined is not a function" and it highlights the row 97 of editor.select2.js
The error suggests that the
select2
library has not been loaded. Have you included the required Javascript and CSS files for select2?Allan
Ok, I regenerated the example page with the datatable generator.
Here you can find the HTML and the js : http://live.datatables.net/upgrade/2/edit?html,js,output or here: https://gist.github.com/anonymous/78790baa8b21d98a9899
The browser wrote "Uncaught TypeError: Cannot read property 'create' of undefined".
I don't know the reason.
Okay great - so I see that select2 is being included. But it doesn't look like you are including the Editor select2 plug-in?
Allan
I do not know why the previous times did not work (I had performed the same procedure), but the important thing is that now it works.
Thank yopu very much.