I have implemented a jquery Datatable with datatables.editable and Jeditable. I am able to use a text area as an editable field but I am having problems setting up a Select as the editable.I have the following code to initialise the editable: \[code\]oTable.makeEditable({ sUpdateURL: "../ReconService.asmx/UpdateUser", "aoColumns": [ null, null, { indicator: 'Updating user...", tooltip: "Change user", type: "select", submit: "Save", data: getUserFilterOptions() } ] });\[/code\]I then have a javascript / jquery function to get a list of users from the DB. Within the function I have tried a number of different things. The function as it stands now manually assembles the string to the format specified on the website jeditableThe function I have is as follows: \[code\]function getUserFilterOptions() { $.ajax({ type:"POST", contentType: "application/json; charset=utf-8", url: "../ReconService.asmx/GetUsers", dataType: "json", success: function(result){ var userResult = result.d; if (userResult.length > 0){ var text = "{'Select':'Select',"; $.each(userResult, function(index, val) { text += "'"; text += val["value"]; text += "':'"; text += val["value"]; text += "'"; text += ","; }); text += "'selected:'Select'}"; return text; } }, }); }\[/code\]I have used the developer tools in Chrome to step through the function and the function returns the following string:
"{'Select':'Select','Administrator':'Administrator','User1':'User 1','selected':'Select'}"
The format is correct as far as i can tell but when I click on the editable table cell I get an error: \[quote\] Uncaught SyntaxError: Unexpected end of input jquery.jeditable.mini.js:34 $.editable.types.select.content jquery.jeditable.mini.js:34 $.fn.editable.each.reset.self.editing jquery.jeditable.mini.js:18 jQuery.event.dispatch jquery-1.8.3.js:3058 jQuery.event.add.elemData.handle.eventHandle jquery-1.8.3.js:2676\[/quote\]The confusing things is, if I copy that string value and put it directly into the data parameter of the jeditable it works fine. I have even created a function to just return this literal string and it works fine.Example, replace the contents of the function as follows: \[code\]function getUserFilterOptions(){ return "{'Select':'Select','Administrator':'Administrator','User1':'User 1','selected':'Select'}" } \[/code\]This works fine.Im not an expert in javascript so any help is much appreciated.
"{'Select':'Select','Administrator':'Administrator','User1':'User 1','selected':'Select'}"
The format is correct as far as i can tell but when I click on the editable table cell I get an error: \[quote\] Uncaught SyntaxError: Unexpected end of input jquery.jeditable.mini.js:34 $.editable.types.select.content jquery.jeditable.mini.js:34 $.fn.editable.each.reset.self.editing jquery.jeditable.mini.js:18 jQuery.event.dispatch jquery-1.8.3.js:3058 jQuery.event.add.elemData.handle.eventHandle jquery-1.8.3.js:2676\[/quote\]The confusing things is, if I copy that string value and put it directly into the data parameter of the jeditable it works fine. I have even created a function to just return this literal string and it works fine.Example, replace the contents of the function as follows: \[code\]function getUserFilterOptions(){ return "{'Select':'Select','Administrator':'Administrator','User1':'User 1','selected':'Select'}" } \[/code\]This works fine.Im not an expert in javascript so any help is much appreciated.