請幫助基本上我想過濾我的數據表使用窗體。codeigniter datatables從表單獲取數據
每個輸入的值都會影響查詢和提交的表單。
這是我的JQUERY。
$("#submit").click(function (e) {
$('#table').dataTable
({
"sAjaxSource": "index.php/report/get_report",
"sServerMethod": "POST",
'fnServerData': function (url, data, callback) {
// Add new data
dataString = $("#myform").serialize();
$.ajax({
'url': "index.php/report/get_report",
'data': dataString,
'type': 'POST',
'success': callback,
'dataType': 'json',
'cache': true
});
},
'bServerSide' : true,
"aaSorting": [[ 3, "desc" ]],
"bPaginate": true,
"bSortClasses": false,
"bAutoWidth": true,
"bInfo": true,
"iDisplayLength" : 3,
"bScrollCollapse": true,
"oLanguage": {
"sSearch": "Search:"
},
"bDestroy": true
});
});
,這是我的HTML表單
<form name="myform">
<label>Employee:</label>
<input type="text" name="employeeid" id="employeeid" title="Type Employee" />
<label>Training Type: </label>
<select name="trainingtype" id="trainingtype" >
<option value="" selected="selected">All</option>
<option value="1">Externally Facilitated Training</option>
<option value="3">Internally Facilitated Training</option>
<option value="2">Webcast/E-Learning</option>
</select>
<label>Datestart</label>
<input type="text" class="field size3" name="datestart" id="datepicker_s" />
<label>Dateend </label>
<input type="text" class="field size3" name="dateend" id="datepicker_e" />
<input type="hidden" id="txtsearchid" name="txtsearchid">
<input type="button" class="button" value="Submit" id="submit" />
當我提交表單我什麼也沒得到。
我正在做正確的方法?
請幫忙。
GOT IT
"fnServerData": function (sSource, aoData, fnCallback) {
//REQUIRED: Add a Post variable with the object value
aoData.push(
{ "name": "txtsearchid", "value": $("#txtsearchid").val() },
{ "name": "datestart", "value": $("#datepicker_s").val() },
{ "name": "dateend", "value": $("#datepicker_e").val() },
{ "name": "trainingtype", "value": $("#trainingtype").val() }
);
$.ajax({
dataType: 'json',
type: "POST",
url: sSource,
data: aoData ,
success: fnCallback
});
},
這肯定是我的問題的解決方案。我沒有使用的序列化,而不是推
http://www.grocerycrud.com/你可能想看看雜貨店CRUD,建於數據表/ flexigrid圖書館codeigniter,節省您的代碼從更長的行代碼,如果你想使用數據表的時間 – tomexsans 2013-03-11 07:49:48
謝謝我已經找到了解決方案 – 2013-03-11 08:30:34