Cannot Filter the datatable by changing dropdownlist in mvc2?

Cannot Filter the datatable by changing dropdownlist in mvc2?

narsareddyanarsareddya Posts: 1Questions: 0Answers: 0
edited May 2010 in General
Hi,

i have dropdownlist out of data table, depends on user selection in dropdownlist then datatable will be displayed records..

It's working for only first selections for ex: in dropdownlist values x,y and z. if i select "x" then datatable is displaying accroding "x" related. again if i select "y" or "z"then it is displaying messagebox " DataTables warning: Unable to re-initialise DataTable. Please use the API to make any configuration changes required."

Code:


$(function() {
$("#Users").change(function() { ' Users -- dropdownlist id
var selectedItem = $(this).val();

//ready function
var gaiSelected = [];
var oTable;

$(document).ready(function() {
oTable = $("#tblService1Index").dataTable({
"bJQueryUI": true,
"oLanguage": {
"sLengthMenu": 'Display ' +
'10' +
'20' +
'30' +
'40' +
'50' +
'All' +
' records'
},
"sPaginationType": "full_numbers",
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
if (jQuery.inArray(aData[0], gaiSelected) != -1) {
$(nRow).addClass('row_selected');
}
return nRow;
},
"aoColumns": [
{ "bSortable": true, "bVisible": false },
{ "bSortable": true, "fnRender": function(aobj)
{ return '' + aobj.aData[1] + ''; }
},
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true },
{ "bSortable": true, "bVisible": false },
{ "bSortable": true },
{ "bSortable": true, "fnRender": function(aobj) {
return 'Subscribe';
}
}],
"sAjaxSource": '<%= ResolveUrl("~/Service/GetSubScrListbyHost?aintEntityId=" )%>' + selectedItem
});

});


});
});


Plz help me on this..

Thank You,
Narsa Reddy.
This discussion has been closed.