ExtJS与.NET结合开发实例系列:
1.ExtJS与.NET结合开发实例(Grid 之数据显示、分页、排序篇)
2.ExtJS与.NET结合开发实例(Grid之批量删 除篇)
感谢大家对两篇文章的关注,我将尽力帮助需要用到ExtJS开发的 朋友去解决开发中遇到的问题.
言归正传,我们新增记录功能的步骤如下:
1.新建 FORM
FORM的建立是用ExtJS实现在GridForProjectLists.js文件中的。注 意的是,我同时做了个ExtJS的ComboBox
ComboBox实 现:
1var storeDept = new Ext.data.Store({
2 proxy: new Ext.data.HttpProxy({
3 url:"../Projects/JsonDataSource/DepartmentInfo.aspx"
4 }),
5 // create reader that reads the project records
6 reader: new Ext.data.JsonReader({}, [
7 {name:'Text',type:'string'},
8 {name:'Value',type:'string'}
9 ])
10 });
11 storeDept.load();
12
13 var storeStatus = new Ext.data.Store({
14 proxy: new Ext.data.HttpProxy({
15 url:"../Projects/JsonDataSource/GetProjectStatus.aspx"
16 }),
17 // create reader that reads the project records
18 reader: new Ext.data.JsonReader ({},[
19 {name:'NAME',type:'string'},
20 {name:'CODE',type:'string'}
21 ])
22 });
23
storeStatus.load(); 这里的实现了两个 ComboBox,一个是部门选择,一个是状态选择。我这里只说其中一个数据源的写 法,即GetProjectStatus.aspx。
新建GetProjectStatus.aspx文件,代 码如下:
GetProjectStatus.aspx
1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetProjectStatus.aspx.cs" Inherits="Web.Projects.JsonDataSource.GetProjectStatus" % >
2<%=strJsonSource %> 1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Linq;
6using System.Web;
7using System.Web.Security;
8using System.Web.UI;
9using System.Web.UI.WebControls;
10using System.Web.UI.WebControls.WebParts;
11using System.Web.UI.HtmlControls;
12using System.Xml.Linq;
13using BusinessObject.Projects;
14using Database;
15using Web.Components;
16namespace Web.Projects.JsonDataSource
17 {
18 public partial class GetProjectStatus : System.Web.UI.Page
19 {
20 protected string strJsonSource = string.Empty;
21 protected void Page_Load (object sender, EventArgs e)
22 {
23 GetJsonSouceString();
24 }
25
26 //这些不 用我注释了吧,呵呵
27 private void GetJsonSouceString()
28 {
29 ProjectDictDataContext db = new ProjectDictDataContext();
30 var query = from p in db.PROJECT_DICTs
31 where p.DICT_TYPE == "003"
32 select new { p.NAME, p.CODE };
33 strJsonSource = query.ToJSON();
34 }
35 }
36}
37