admin 管理员组文章数量: 1086019
I am new to jquery and I have used the jqueryData Table, I am facing problem in during search,
Search is working for first two columns (ex., if I search using 'QE5855' or 3453457 its working fine),
But its not searching for the third column (ex., if I enter 'United' or 'united states' table is not getting sorted) , Please help me.
<table id="agentDetails">
<tr style="">
<th width="22%">User Id</th>
<th width="20%">Parent Id</th>
<th width="35%">Country</th>
</tr>
<%
for(UserDataModel getEachEmpDetails:phoneIdSiteMappingList){
%>
<tr>
<td> <div><%=getEachEmpDetails.getUserUid %> </div> </td> // data is like 'QE5855'
<td><div><%=getEachEmpDetails.getParentUid %> </div> </td> //data is like '3453457'
<td><div><%=getEachEmpDetails.getCountry %> </div> </td>// data is like 'United States'
</tr>
<%
}
<%
<script type="text/javascript">
$( document ).ready(function() {
var table = $("#agentDetails").DataTable({
"bSort": false,
"iDisplayLength": 10 ,
"sPaginationType": "full_numbers",
"bSearchable":true,
"bPaginate": true,
"bFilter": true,
"sDom": '<"top"fip>',
"bStateSave": false,
"oLanguage": {
"sInfo": "Showing _START_ to _END_ of _TOTAL_ messages",
"sInfoEmpty": "Showing 0 to 0 of 0 messages",
"sEmptyTable": " ",
"sSearch": "   ",
"oPaginate": {
"sPrevious": "<",
"sNext": ">",
"sFirst":"",
"sLast":""
},
dom: 'T<"clear">lfrtip',
tableTools: {
"sRowSelect": "single"
}
}
});
});
<script>
I am new to jquery and I have used the jqueryData Table, I am facing problem in during search,
Search is working for first two columns (ex., if I search using 'QE5855' or 3453457 its working fine),
But its not searching for the third column (ex., if I enter 'United' or 'united states' table is not getting sorted) , Please help me.
<table id="agentDetails">
<tr style="">
<th width="22%">User Id</th>
<th width="20%">Parent Id</th>
<th width="35%">Country</th>
</tr>
<%
for(UserDataModel getEachEmpDetails:phoneIdSiteMappingList){
%>
<tr>
<td> <div><%=getEachEmpDetails.getUserUid %> </div> </td> // data is like 'QE5855'
<td><div><%=getEachEmpDetails.getParentUid %> </div> </td> //data is like '3453457'
<td><div><%=getEachEmpDetails.getCountry %> </div> </td>// data is like 'United States'
</tr>
<%
}
<%
<script type="text/javascript">
$( document ).ready(function() {
var table = $("#agentDetails").DataTable({
"bSort": false,
"iDisplayLength": 10 ,
"sPaginationType": "full_numbers",
"bSearchable":true,
"bPaginate": true,
"bFilter": true,
"sDom": '<"top"fip>',
"bStateSave": false,
"oLanguage": {
"sInfo": "Showing _START_ to _END_ of _TOTAL_ messages",
"sInfoEmpty": "Showing 0 to 0 of 0 messages",
"sEmptyTable": " ",
"sSearch": "   ",
"oPaginate": {
"sPrevious": "<",
"sNext": ">",
"sFirst":"",
"sLast":""
},
dom: 'T<"clear">lfrtip',
tableTools: {
"sRowSelect": "single"
}
}
});
});
<script>
Share
Improve this question
asked Jun 10, 2016 at 15:05
KhusbooKhusboo
1171 gold badge1 silver badge9 bronze badges
1 Answer
Reset to default 3I'm not sure which version of Datatable are you using but I hope this helps. I should to say that I didn't test it, so the example is just the main idea where I think the problem is.
On your JS code you can indicate the source from you want to retrieve the data on the table, in this case I'm using C# so I use "Url.Action". You should to indicate that in sAjaxSource. Example is something like this...
var oTable;
$(function() {
oTable = $('#agentDetails')
.dataTable({
"bServerSide": true,
"bProcessing": true,
"bSort": true,
"sAjaxSource": "@Url.Action("Method")",
"sPaginationType": "full_numbers",
"bSearchable":true,
"bFilter": true,
"sDom": '<"top"fip>',
"bInfo": true,
"bLengthChange": false,
"aoColumns": [
{ "mData": "UserId" },
{ "mData": "ParentId", "width": "22%", "bSortable": true},
{ "mData": "Country", "width": "35%" },
],
});
On aoColumns "mData" means the way than you al mapping the date that are you getting of your method so you should exactly the name of the var that contains that value in your model. After that you don't need to use a for clause and the datatable should to be able to handled the searching and filter for it self.
Example
<table id="agentDetails" >
<thead>
<tr>
<th>User Id</th>
<th>Parent Id</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
本文标签: javascriptjquery dataTable filtersearch not workingStack Overflow
版权声明:本文标题:javascript - jquery dataTable filtersearch not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744028224a2521019.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论