我正在尝试快速加载数据并在下面使用javascript和sql查询。但加载速度很慢。
ALTER Procedure [dbo].[Proc_LoadAllVehicles2]
as
Declare @DisplayLength int
SET @DisplayLength =5000
Declare @DisplayStart int
SET @DisplayStart = 0
Declare @Search nvarchar(100)
SET @Search = ''
Declare @SortCol int
SET @SortCol = ''
Declare @SortDirec nvarchar(100)
SET @SortDirec = ''
Declare @FirstRecord int ,@LastRecord int
set @FirstRecord = @DisplayStart;
set @LastRecord = @DisplayStart + @DisplayLength;
With t_Vehicle_Detail
as
(
Select *, ROW_NUMBER() OVER (ORDER BY Vehicle_Detail.Serial_no DESC)
as RowNum
FROM Vehicle_Detail
where ( @Search LIKE '%'+@Search+'%' )
)
SELECT * FROM t_Vehicle_Detail where RowNum>@FirstRecord and RowNum <= @LastRecord
和
function LoadAllTrucksList() {
debugger;
$.ajax({
type: "POST",
url: "Trucks.asmx/LoadAllTrucksList",
data: '{}',
contentType: "application/json; charset=utf-8",
datatype: "json",
success: function (response) {
var obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
if (obj.retCode == 1) {
debugger
Arr = obj.dtTable;
var ul = '';
//$("#tbl_Detail").empty();
// var ToatlDueAmount = 0;
//$("#LocationDetails").empty();
for (var i = 0; i < Arr.length; i++) {
ul += '<tr class="odd">';
//ul += '<td class=" ">' + parseInt(i + 1) + '</td>';
ul += '<td class=" " style="vertical-align: top;min-width:100px;"><small>' + Arr[i].Vehicle_no + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Loading_Date + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Unloading_Date + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Weight + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Rate + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].FrieghtAmount + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Advance + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Balance + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].FromCity + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].ToCity + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Material + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Party + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Owner + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].DriverName + '</small></td>';
ul += '<td class=" "><small>' + Arr[i].Remarks + '</small></td>';
ul += '<td class=" "><a class="glyphicon glyphicon-edit" style="cursor:pointer" title="Edit" href="EditTrucksDetails.aspx?Regiud=' + Arr[i].Serial_no + '"></a></td> '
//ul += '<td class=" ">' + Arr[i].ContactNo + '</td>';
//ul += '<td class=" ">' + Arr[i].NoOfInfants + '</td>';
// ul += '<td class=" "><span class="glyphicon glyphicon-trash" style="cursor:pointer" title="Delete" onclick="Delete(' + Arr[i].nID + ')"></span></td>';
ul += '</tr>';
}
$("#tbl_Detail tbody").empty();
$("#tbl_Detail tbody").append(ul);
$("#tbl_Detail").dataTable({
"bSort": false,
"processing": true, // control the processing indicator.
"serverSide": true, // recommended to use serverSide when data is more than 10000 rows for performance reasons
"info": true, // control table information display field
"stateSave": true, //restore table state on page reload,
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]],
"dataSrc": ""
});
document.getElementById("tbl_Detail");
}
else if (obj.retCode == 0) {
$("#tbl_Detail").empty();
ul += '<tr>';
ul += '<td colspan="5">No Record Found</td>'
ul += '</tr>';
$('#tbl_Detail').append(ul);
}
// $('#tbl_Detail tbody').append(ul);
}
});
}