how to send data param to controller by using datatabel
how to send data param to controller by using datatabel
yogi1982
Posts: 2Questions: 2Answers: 0
i am trying to get list view on from date and to date param bu i cant understand how to do
jquery
$("#PTable").dataTable({
"serverSide": true,
"ajax": {
"type": "POST",
"url": "/Perchus/ListGetINV3",
"data": function (data) { return data = JSON.stringify(data) },
"data": '{"txtFromDate":"txtFromDate" ,"txtToDate":"txtToDate" }',
"contentType": 'application/json; charset=utf-8',
"datatype": "json"
},
"columns": [
{ "data": "SypplyerName", "orderable": true },
{ "data": "InvoiceNo", "orderable": true },
{ "data": "InvoiceDate", "orderable": true },
{ "data": "TaxAmount", "orderable": true },
{ "data": "TotalAmount", "orderable": true },
],
//"order": [[0, "asc"]]
});
controller
[HttpPost]
public JsonResult ListGetINV3(DateTime txtFromDate,DateTime txtToDate)
{
PerchesTransaction pt = new PerchesTransaction();
var pdata = dc.PerchesTransactions.Where(m=>m.InvoiceDate >= txtFromDate && m.InvoiceDate <= txtToDate).ToList();
return Json(pdata, JsonRequestBehavior.AllowGet);
}
This discussion has been closed.
Answers
Hi @yogi1982 m
You've got
ajax.data
declared twice - there should be only the one.Cheers,
Colin
thanks , colin
but he say error
DataTables warning: table id=PTable - Ajax error. For more information about this error, please see http://datatables.net/tn/7
and didn't show any data
"ajax": {
"type": "POST",
"url": "/Perchus/ListGetINV3",
"data":'{"txtFromDate":"txtFromDate","txtToDate":"txtToDate"}',
"contentType": 'application/json; charset=utf-8',
"datatype": "json"
},
Follow this link in the message for troubleshooting steps:
http://datatables.net/tn/7
Let us know what you find.
Kevin