我有一个标签式数据表,我想添加“全部”选项。我的菜单长度。
我有10个,25个,50个,75个都可以正常使用,但是所有的'选项返回"显示100个条目中的1到0" ...在萤火虫中我可以看到选择'全部' aaData为空。我错过了一个特定的参数吗?感谢。
JS:
`$('#datatable').dataTable({
"aaSorting": [[0, 'asc']],
"sDom": '<"H"lr>t<"F"ip>', // Specifies where to inject controls
"bJQueryUI": true,
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bStateSave": true,
"iDisplayLength": 10,
"aLengthMenu": [[10, 25, 50, 75, -1], [10, 25, 50, 75, "All"]],
"bLengthChange": true,
"bPaginate": true,
"bServerSide": true,
"sAjaxSource": 'datatable.json',
"aoColumnDefs": [
{
"fnRender": function(oObj, sVal) {
return '<a class="ui-icon ui-icon-pencil" title="Edit" href="oObj.aData[0]">Edit</a>';
},
"bSortable": false,
"aTargets": [2]
}
],
/* The following lines are used to send extra data to the server */
"fnServerData": function(sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function(json) {
fnCallback(json);
});
}
}).columnFilter({aoColumns: [{type: "text"}, {type: "text"}]});`
JSON:
@RequestMapping(value = "datatable.json", method = RequestMethod.GET)
@ResponseBody
public Page getDataTablePage(
@RequestParam int sEcho,
@RequestParam int iColumns,
@RequestParam int iSortCol_0,
@RequestParam String sSortDir_0,
@RequestParam String sSearch_0,
@RequestParam String sSearch_1,
@RequestParam int iDisplayStart,
@RequestParam int iDisplayLength) {
logger.info("Inside " + ((StackTraceElement[]) Thread.currentThread().getStackTrace())[1]);
Integer total = service.getCount();
Integer totalMatching = service.getCountBySearch(sSearch_0, sSearch_1);
List<Data> rowData = service.getPage(iDisplayStart, iDisplayLength, iSortCol_0, sSortDir_0,
sSearch_0, sSearch_1);
Page p = new Page();
p.setsEcho(sEcho);
p.setiTotalRecords(total);
p.setiTotalDisplayRecords(totalMatching);
// Convert list of unordered hashmaps into 2D array for DataTables
String[][] pageData = new String[rowData.size()][iColumns];
// For each row
for (int r = 0; r < rowData.size(); r++) {
Data d = rowData.get(r);
pageData[r][0] = d.getItem1();
pageData[r][1] = d.getItem2();
}
p.setaaData(pageData);
logger.info("p=" + p);
return p;
}
MyBatis的
<select id = "getPage" parameterType="map" resultType="com.ti.ds.psi.domain.Data">
SELECT * FROM (
SELECT rownum rn, s.* FROM (
SELECT item1, item2
FROM items
WHERE upper(item1) like '%'||upper(#{sSearch_0})||'%'
AND upper(item2) like '%'||upper(#{sSearch_1})||'%'
ORDER BY
<choose>
<when test="sidx==0">item1</when>
<when test="sidx==1">item2</when>
</choose>
${sord}
) s
)
WHERE rn BETWEEN #{start} AND #{start} + #{rows}
</select>
答案 0 :(得分:1)
修正了..我在查询中添加了一个简单的部分 - &#39;或者#{rows} = -1&#39;。
&#39;行&#39;被定义为我的桌子长度。
感谢。