editor.ajax.reload is not a function
editor.ajax.reload is not a function
dynasoft
Posts: 446Questions: 69Answers: 3
Hi
I'm trying to call a reload on an editor table as per below:
var editor = null;
jQuery(function($){
LoadTypes();
setInterval( function () {
editor.ajax.reload(null, false);
}, 10000 );
});
}
function LoadTypes() {
editor = new $.fn.dataTable.Editor({
...
}
But keep getting error 'editor.ajax.reload is not a function'. Thanks.
This discussion has been closed.
Answers
ajax.reload() is a DataTable API method, not an Editor method.
Thanks. Is there an equivalent or Editor?
for Editor
Got it to work w/ this example: https://editor.datatables.net/examples/extensions/rowReorder. Thanks.
Still have an issue. I load data in select fields when eidor object gets created. How can I reload/recreate the editor object? If I try and call the same initial code I get error https://datatables.net/manual/tech-notes/3
Did you follow the steps in the technote?
https://datatables.net/manual/tech-notes/3
It has the troubleshooting steps to resolve the problem.
Kevin
Hi
Yes I did but that page covers working w/ DataTable not the Editor object created via editor = new $.fn.dataTable.Editor. I'm able to reload the table either via dataTable.ajax.reload(null, false); or by setting dataTable.destroy(); and calling the javascript that loads the table and sets editor again but the code only hits reloading the table and not recreating the editor object where my select's are located. Even if I set editor = null, the creation of the editor object is not reached. I know that because in that part I have razor code which gets hit in VS only on loading the page but not on calling that js function that sets the table and creates the editor object. Any idea? Thanks.
If I place code above in a function and call itlike so:
The ViewBag razor code is never reached as the cursor just stays on 'editor = new $.fn.dataTable.Editor' and the GroupName select is never updated wit hthe content of the ViewBag.
Editor doesn't have an API reload or destroy it.
I'm not sure I understand the problem you are trying to solve. Please explain what you are trying to do/solve so we can try to provide a solution.
Kevin
Hi. I have a select called GroupName whose options need to be reloaded after initially loading the table via a MVC view.
Ah - in that case use
field().update()
to update the list of options for aselect
.Allan
Thanks
How can I set tis with an array:
Thanks.
I'm afraid I don't understand the question. You've defined an array there. Running that in the console shows:
Allan
This returns a single string with all flags whereas I need each flag extracted separately as individual array member.
or
return a single line/select option with all flags rather than one select option per array member
Please see screenshot.
That is a Javascript array, not a string.
I don't really understand what you want.
Hi, the string is how editor displays the array. Please see the screenshot. I need as explained one array member per select option.
This also gives the same (wrong) behaviour:
This
editor.field('GroupName').update( [
'USA','Brazil','Germany','Canada'
] );
gives the expected result, as per below:
But I can't set the update method with the individual members as its something that can't be hardcoded, but taken from an array.
The array is populated from an ajax call. I guess another way of putting this is how can I set the values for this update method and not hardcode them?
This is an array:
var flags = ['USA','Brazil','Germany','Canada'];
You have this:
This is passing an array inside an array to the update method, which I don't think you want. I think you want this:
Note I removed the
[]
surrounding flags.Kevin
It's been a long day. Thank you very much. That worked.