前台Extjs代码:
Ext.onReady(function () {
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: "/WebService/test/tb_data.ashx" }),
reader: new Ext.data.JsonReader({
totalProperty: "results",
root: "jsonObjs"
},
[
{ name: 'user_name' },
{ name: 'user_id' },
{ name: 'ssyj' }
]
),
listeners: {
load: function () {
alert(store.getCount());
}
}
});
store.load();
});
后台代码:
public void ProcessRequest(HttpContext context)
{
context.Request.ContentEncoding = Encoding.GetEncoding("UTF-8");
context.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
context.Response.Charset = "UTF-8";
context.Response.ContentType = "text/plain";
string result = string.Empty;
string ygk_list = string.Empty;
string strSQL = string.Empty;
try
{
strSQL = string.Format(@"select tb_user.user_name,tb_fwcjqr.user_id,sum(tb_fwcjqr.htzj)as ssyj from tb_fwcjqr
inner join tb_user on tb_user.id = tb_fwcjqr.user_id
group by tb_user.user_name ,tb_fwcjqr.user_id");
DataTable dt = LTP.DBUtility.DbHelperSQL.Query(strSQL).Tables[0];
if (dt.Rows.Count > 0)
{
result = LTP.BLL.Ext_Json.DataTable2Json(dt);
}
else
{
result = "false";
}