C# 如何在AngularJS数据表中使用deferRender?
我试过这个代码 HTML代码C# 如何在AngularJS数据表中使用deferRender?,c#,html,angularjs,web-services,C#,Html,Angularjs,Web Services,我试过这个代码 HTML代码 <table id="example" data-datatable="ng"> <thead> <tr> <th>S.No</th> <th>Menu Name</th> <th>Menu Link</th> <th>Menu Path</th> <th&g
<table id="example" data-datatable="ng">
<thead>
<tr>
<th>S.No</th>
<th>Menu Name</th>
<th>Menu Link</th>
<th>Menu Path</th>
<th>Icon</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="x in names">
<td>{{x.iMenu_id}}</td>
<td>{{x.cMenu_Name}}</td>
<td>{{x.cLink}}</td>
<td>{{x.cHelpLink}}</td>
<td>{{x.cCss_Class}}</td>
</tr>
</tbody>
</table>
public class HelloWorldData
{
public String Message;
}
[WebMethod]
public void Page_Select()
{
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Clear();
Context.Response.ContentType = "application/json";
HelloWorldData data = new HelloWorldData();
string sql = "Exec PB_GetMasterDetails @opt=20";
SqlDataAdapter da = new SqlDataAdapter(sql, System.Configuration.ConfigurationManager.AppSettings["BB_CONSTR"]);
DataSet ds = new DataSet();
da.Fill(ds);
Context.Response.Write(JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented));
}
Web服务(C#)代码
<table id="example" data-datatable="ng">
<thead>
<tr>
<th>S.No</th>
<th>Menu Name</th>
<th>Menu Link</th>
<th>Menu Path</th>
<th>Icon</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="x in names">
<td>{{x.iMenu_id}}</td>
<td>{{x.cMenu_Name}}</td>
<td>{{x.cLink}}</td>
<td>{{x.cHelpLink}}</td>
<td>{{x.cCss_Class}}</td>
</tr>
</tbody>
</table>
public class HelloWorldData
{
public String Message;
}
[WebMethod]
public void Page_Select()
{
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Clear();
Context.Response.ContentType = "application/json";
HelloWorldData data = new HelloWorldData();
string sql = "Exec PB_GetMasterDetails @opt=20";
SqlDataAdapter da = new SqlDataAdapter(sql, System.Configuration.ConfigurationManager.AppSettings["BB_CONSTR"]);
DataSet ds = new DataSet();
da.Fill(ds);
Context.Response.Write(JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented));
}
输出
我将在web服务中获得此输出
{
"Table": [
{
"iMenu_id": 10,
"cMenu_Name": "BIRTH REGISTER1",
"cLink": "/Ward/NewIPPatSearch.aspx",
"cHelpLink": "Help/About us/aboutaosta.html",
"cCss_Class": "icon-home"
},
{
"iMenu_id": 14,
"cMenu_Name": "CHANGE PASSWORD",
"cLink": "/UserAdmin/tchangepwd.aspx",
"cHelpLink": "Help/About us/aboutaosta.html",
"cCss_Class": "icon-home"
},
...
...
...
...
...
...
{
"iMenu_id": 2500,
"cMenu_Name": "CITY1",
"cLink": "/Masters/mCity.aspx",
"cHelpLink": "Help/About us/aboutaosta.html",
"cCss_Class": "icon-home"
}
]
}
这种方法对我来说是可行的,但是加载数据需要相当长的时间。所以我尝试了延迟渲染方法,但它对我不起作用。有人知道其他解决方案吗?您应该尝试分析瓶颈在哪里…
以下是我能想到的一些选择: 1.1处理WebRequest(数据库获取)的时间
A1-优化数据库架构或其他优化 1.2将响应数据传输到客户端的时间
A1-您可以压缩数据。
A2-您可以将数据分页到较小的组(~100条记录),这样用户将加载一些数据,并在短时间内获得更多数据,直到收到所有2000多条记录 1.3处理数据客户端的时间。
A1-似乎是合法的,我看不到任何应该减速的东西,但我不是一个棱角分明的忍者。这需要时间。。。。可以从2秒到10年不等。你量过了吗?哪一部分需要时间,执行过程还是序列化为Json?也许两者都有?你要退多少件?那是远程服务器吗?编辑您的问题并提供这些信息。本地服务器。。。加载数据需要5-6秒。。。加载tome由web服务执行。如果直接在数据库上执行该过程,需要多长时间?需要1或2秒。为什么检索
2016
记录时只显示其中的10个。您不应该一次检索10个(分页)以获得更好的性能吗?