how to make sAjaxSource call Dynamic in DT? challenging one

how to make sAjaxSource call Dynamic in DT? challenging one

sunildonsunildon Posts: 40Questions: 7Answers: 0
edited April 2014 in DataTables
Hi Allan & everyone

I am trying to apply a filter i.e DROP DOWN LIST on top of datatable .

I have 3 list items in dropdown i.e my leads,all leads,dead leads . (i binded this static )

Well on my page load The dropdownlist with My leads will be selected and data will be available according to the option choosen in dropdown list . Further if i change anything in dropdown i want my table data to change i.e need to make a call to controller action menthod to fecth data based on dropdonn selection .

I am able to load data to datatable but i have no idea how to send a call back to controller to get data based on dropdown selection before datatable fills its data via ajaxsource?

[quote]I can deal with code at controller i just need a snippet to pass the selected value to controller action method [/quote]

My code :

[code]
$('#myDataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "AjaxHandler", //On my initial load this makes a call to AJAXHANDLER CONTROLLER ACTION METHOD and then datatable will be filled with data .. I WANT TO MAKE THIS DYNAMIC based on dropdown ?
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{
"sName": "Lead_Id"
},
{ "sName": "LeadName" },
{ "sName": "ContactName" },
{ "sName": "CompanyName" },
{ "sName": "AssignTo" },
{ "sName": "LeadStatus" }

]

}); [/code]
Regards

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    If you are using DataTables 1.9.4 use the fnReloadAjax plug-in which allow you to modify the Ajax url: http://datatables.net/plug-ins/api#fnReloadAjax .

    If you are using 1.10, use ajax.url() - http://next.datatables.net/reference/api/ajax.url()

    Allan
  • sunildonsunildon Posts: 40Questions: 7Answers: 0
    Hi

    I am not using either versions sadly . I have compatibility issues lately . when i try to use advanced versions of data-tables i face issue on jquery version ? browser not supported some times .

    Well i am keen on going a ahead with advanced version's . Would you please mention me data-tables compatibility with jquery.js file version and may bootstrap,knockout too . . I will be using IE10 present + mozilla+chrome .

    My version of DataTable is 1.7 and jquery.js is 1.4.4 // sadly i can only move a ahead with this combination which works for me at present where remaining all throws me script exceptions . So any suggestions on this front so i can use above mentioned link to my advantages :)

    Thank you allan
    Regards
    Sunil G
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Wow - that's some old software!

    1.7 is not supported at all anymore, but you could probably hack fnReloadAjax to work with it if you wanted to.

    Allan
  • sunildonsunildon Posts: 40Questions: 7Answers: 0
    Nah mate . I will use lastest which is having less error prone . so shall i go with jquery 1.9 with datatables 1.10 ? which this combinations works ? I get wierd erors like jquery not found , $ not found Lol . Seems to be funny i.e when i use lower version i get no issues .

    I hope please give you best combination where everything should work near best :)

    Regards
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    DataTables 1.10 will work with jQuery 1.7+. If you are getting errors please link to a test case.

    Allan
This discussion has been closed.