저는 지금 당장이 작업을하고 있습니다. 난 datTables를 사용하여 ASP.Net MVC 2 웹 응용 프로그램을 사용하고 있으며 각 테이블에 1000 개 이상의 레코드를 표시해야합니다. 서버 측 처리가 나를 위해가는 길이었습니다. 여기에 우리가 가진 것이 있습니다.
다음은 뷰 (/ Admin/Unassigned)의 선언입니다.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#adminUnassignedTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Admin/UnassignedTable"
});
});
</script>
여기 컨트롤러 기능 (/ Admin/UnassignedTable)이 있습니다.
public void UnassignedTable()
{
statusID = (int)PTA.Helpers.Constants.Queue;
locationID = (int)PTA.Helpers.Constants.Reviewer;
_AdminList = PTA.Models.IPBRepository.GetIPBsByStatus(Convert.ToInt32(statusID), Convert.ToInt32(locationID)); //_AdminList is an IEnumerable<IPB>, IPB being our class
IEnumerable<IPB> _NewList;
int nDisplayStart = Convert.ToInt32(HttpContext.Request.QueryString.Get("iDisplayStart");
int nDisplayLength = Convert.ToInt32(HttpContext.Request.QueryString.Get("iDisplayLength");
_NewList = _AdminList.Skip<IPB>(nDisplayStart).Take<IPB>(nDisplayLength).ToList<IPB>();
string strOutput = "{";
strOutput += "\"sEcho\":" + HttpContext.Request.QueryString.Get("sEcho") + ", ";
strOutput += "\"iTotalRecords\":" + _AdminList.Count().ToString() + ", ";
strOutput += "\"iTotalDisplayRecords\":" + _AdminList.Count().ToString() + ", ";
strOutput += "\"aaData\":[";
foreach (IPB ipb in _NewList)
{
strOutput += "[ ";
strOutput += "\"" + ipb.IPBName + "\",";
strOutput += "\"" + ipb.PubDate + "\",";
strOutput += "\"" + ipb.Change + "\",";
strOutput += "\"" + ipb.ChangeDate + "\",";
strOutput += "\"" + ipb.TotalParts + "\",";
strOutput += "\"" + ipb.TotalPartsReports + "\",";
strOutput += "\"" + ipb.ALC + "\",";
strOutput += "\"" + ipb.DateAdded + "\",";
strOutput += "\"" + "" + "\","; //Need to add drop down control, that's why it's blank.
strOutput += "\"" + "" + "\","; //Need to add drop down control, that's why it's blank.
strOutput += "\"" + "" + "\","; //Need to add drop down control, that's why it's blank.
strOutput += "\"" + "" + "\""; //Need to add drop down control, that's why it's blank.
strOutput += "]";
if (ipb != _NewList.Last())
{
strOutput += ", ";
}
}
strOutput += "]}";
Response.Write(strOutput);
}
참고 !!!!!!! 컨트롤을 추가 할 때 백 슬래시가 JSON 데이터에 있어야하기 때문에 컨트롤 값의 따옴표를 \\ "로해야합니다.
컨트롤러에서 웹 서비스에 액세스 할 수 있기를 바랍니다. 웹 프로그래밍, 그래서 당신이. 난 그냥이 도움이 될 생각해야 할 것입니다 모르겠어요.
여기
감사합니다, 아니요 - PHP를 사용하지 않고 있습니다. 이것은 asp.net 응용 프로그램입니다. 또한 asp.net 웹 서비스를 사용하여 데이터를 가져옵니다. 그래서 내가 그것을하고 싶은 것은 DataTables의 초기화 루틴에서 직접 asp.net 웹 서비스에 액세스합니다. .php 나 .aspx와 같은 서버 페이지가 아니라 웹 서비스. 나는 실제로 그것을 아직 시도하지 않았으며 이것이 단지 받아 들여지는 관행인지 아닌지 궁금해하고 있습니다. 또는 그것이 가능한지 여부 ... – sarsnake
두 사람이 서로를 이해하지 못한다고 생각합니다 :) @gnomixa는 서버에 추가 데이터를 전달하고 싶지 않았습니다. @Reigel은 PHP를 고집하지 않았습니다. –
나는 그것이 가능할 것 같아요 ... 글쎄, 난 asp.net의 마스터가 아니지만 당신은 단지 datatables.net에 json을 전달해야한다고 생각하고 그것에 아무런 문제가되지 않습니다. 나는 생각한다. – Reigel