I am using inline editable datatable, I have a dropdown Markup like
function editRow(oTable, nRow) {
var aData = oTable.fnGetData(nRow);
var jqTds = $('>td', nRow);
jqTds[0].innerHTML = '<select id="userrole" class="form-control input-sm"></select>';
}
From Server side I am getting values as JSON.
success: function (data) {
//alert("success");
var userdata=JSON.parse(data);
// alert(userdata);
for(i=0;i<userdata.length;i++)
{
//alert(userdata[i].rolename)
$('#userrole').append('<option value="'+userdata[i].roleid+'" selected="selected">'+userdata[i].roleid+'</option>');
};
I need to append the values to selectbox, But, its not working,nothing reflects, i added my ajax script at the bottom of the inline js..Please help
Try adding the data like below:
success: function (data) {
//alert("success");
var userdata=JSON.parse(data);
// alert(userdata);
for(i=0;i<userdata.length;i++)
{
$('<option/>', {
value: userdata[i].roleid,
html: userdata[i].roleid
}).appendTo('#userrole select');
};
$('#userrole select option:first-child').attr("selected", "selected");