我正在该页面上工作并使用在不同屏幕上使用的现有存储过程。
我有一个代码可以显示存储过程的整个结果。 我只需显示检索到的整个记录列表中的最后 40 条记录。
这是我使用的代码片段:
......
myself.get_Service().SearchRecords(myID, '', '', function (result) {
myself.get_Service().GetRecords(result, function (result) {
RecordNotes = new Array();
for (var ctr = 0; ctr < result.length; ctr++) {
var record = result[ctr];
RecordsNotes[RecordNotes.length] = new Array(record.CreatedDate.toString("MM/dd/yyyy HH:mm:ss"), record.CreatedBy, record.CategoryName == null ? '' : record.CategoryName, record.Note);
}
$('#tblRecordNotes').dataTable().fnClearTable();
$('#tblRecordNotes').dataTable().fnAddData(RecordNotes);
});
$("#txt_RecordNote").val("")
$("#ddlCategories").prop('selectedIndex', 0);
});
......
如何仅显示 result
对象中的最后 40 条记录?
最佳答案
如果结果超过40条记录,可以slice
结果如下:
result.slice(-40);
关于javascript - 如何使用客户端java脚本显示通过web服务接收的最后N条记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41703581/