extjs获取后台数据(asp.net)

在extjs中,我们用Ext.data.Store类来处理数据,首先需要为它指定url以加载数据的地址,还要指定Ext.data.Reader解码数据的方式、例子中,服务器将返回json数据,因而我们需要使用JsonReader读取数据。

Store不但支持本地排序、筛选和分组,也支持远程排序、筛选和分组。

var ALLProjectstore = new Ext.data.Store({ proxy: new Ext.data.HttpProxy( { url: "DATA/project/Project.aspx", method: "POST" }), listeners: { load: function () { combo1.setValue(seid); //设置combox初始值 Ext.getCmp('txt').setText(combo1.getRawValue()); //为label动态赋值为“当前项目名称” } } , reader: new Ext.data.JsonReader( { fields: ["id", "text", "picture"], root: "data", id: "id", totalProperty: "totalCount" }) }); ALLProjectstore.load();  

获取数据的地址为DATA/project/Project.aspx

.aspx中写成<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetCustomerInfo.aspx.cs" Inherits="DATA_customer_GetCustomerInfo" %> <%= ParamJSON%>

.cs中写成using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Maticsoft.BLL; public partial class DATA_customer_GetCustomerInfo : System.Web.UI.Page { public string ParamJSON = ""; customer bll = new customer(); protected void Page_Load(object sender, EventArgs e) { string project_id = Request.Form["project_id"]; int id = 0; if (project_id != string.Empty) { id = Convert.ToInt32(project_id); } GetOrderJSON("project_id=" + id); } public void GetOrderJSON(string strwhere) { //int id = Convert.ToInt32(Request.Form["id"]); ParamJSON = bll.getCustomerInfo(strwhere); } }

你可能感兴趣的:(String,function,object,url,asp.net,ExtJs)