Need to fill the datatable on click of a button. [Urgent]

Need to fill the datatable on click of a button. [Urgent]

dasharathdasharath Posts: 4Questions: 0Answers: 0
edited October 2010 in General
Hi i need to fill the datatable on click of a button.

this is the code that i have written on Load of the form
[code]
$('#dtlist').dataTable({
"bPaginate": false,
"bFilter": false,
"bServerSide": true,
"bSort": true,
"sAjaxSource": 'AjaxProcess.aspx?opt=getJsondata',
"fnServerData": function (sSource, aoData, fnCallback) {
aoData.push({ "name": "country", "value": _Country }, { "name": "country", "value": _Country }, { "name": "city", "value": _City });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
}
});
[/code]

The above code fills the data with below option
---------------------------------------------------------------------------
Id First Name Last Name Location Country
1 Raj Kumar Andheri India
2 Rajesh Yadav Juhu India
Showing 1 to 2 of 12 entries

---------------------------------------------------------------------------
Now i hava button on the from where the data is shown. On click of the button i need to get data from the server and re-set it by clearing the existing data.

Below is the function that i have called on Button click
[code]
function FillTable() {
var iCountry = 0;
var iCityList = 0;
if ($("#CountryList").html() != "")
iCountry = $("#CountryList").val();

if ($("#CityList").html() != "")
iCityList = $("#CityList").val();

var oTable;
oTable = $('#dtlist').dataTable();

oTable.push({ "name": "Country", "value": _Country }, { "name": "City", "value": iCityList });
oTable.fnDraw(true);
}
[/code]

Please help it is urgent

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You are using server-side processing, so the data only really "exists" on the server - DataTables is displaying what exists. So all you need to do is call fnDraw. This line:

    [code]
    oTable.push({ "name": "Country", "value": _Country }, { "name": "City", "value": iCityList });
    [/code]
    certainly won't do anything. You've already got it in your fnServerData so are you not seeing those parameters passed to the server?

    Allan
  • dasharathdasharath Posts: 4Questions: 0Answers: 0
    edited October 2010
    How can i reset the filter .
    I want he city to have value 15 instead of 20 When i click on filter button on my form(The city id is default to 20 when loaded).

    On the server i will retrive the data on the basis of city id and send a json result.
This discussion has been closed.