Extjs的combobox使用jsonstore获取asp.net后台数据

shixixi1987 2010-03-24 11:00:04
js源码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>更多Extjs表单项</title>
<link rel="Stylesheet" type="text/css" href="Resources/CSS/ext-all.css" />
<script type="text/javascript" src="Extjs/ext-base-debug.js"></script>
<script type="text/javascript" src="Extjs/ext-all-debug.js"></script>
<script type="text/javascript" src="Extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript">
Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = "Resources/Images/default/s.gif";

/*

var dstore = new Ext.data.JsonStore({
url: "getDepartment.aspx",
fields: ["Name", "Code"],
root: 'rows'
});
dstore.load();


var dateSelect = new Ext.form.FormPanel({
title: "日期选择",
labelSeparator: ':',
labelWidth: 60,
labelAlign: "right",
width: 600,
applyTo: 'dateSelect',
items: [
new Ext.form.DateField({
id: 'dfSelect',
format: 'Y年m月d日',
minValue: '1900-01-01',
maxValue: '3000-01-01',
disabledDaysText: '禁止选择该日期',
fieldLabel: '选择日期',
width: 150,
showToday: true
}),

new Ext.form.ComboBox({
id: "cbDepartment",
fieldLabel: "部门",
triggerAction: "all",
store: dstore,
valueField: "Code",
displayField: "Name",
mode: "local",
forceSection: true,
typeAhead: true,
resizeAble: true
}),

new Ext.form.HtmlEditor({
id: 'htmlContent',
width: 500,
autoHeight: false,
fieldLabel: "HTML编辑"
})
]
});
Ext.MessageBox.alert("Test the return record num", "共获得" + dstore.getCount() + "条数据");

});
</script>
</head>
<body>
<div id="dateSelect"></div>
</body>
</html>

asp.net页面源码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
public partial class getDepartment : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string result = null;
result = "{rows:[{'Name':'开发部', 'Code':'1'}, {'Name':'销售部', 'Code':'2'}, {'Name':'行政部', 'Code':'3'}, {'Name':'质检部', 'Code':'4'}]}";
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.Write(result);
// Response.Write(result);
}
}
}
下拉框得不到数据,请问这段代码哪里有错误?
...全文
456 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
shaoxx86 2010-09-17
  • 打赏
  • 举报
回复
你把combobox 里面的mode: "local",改成mode: "remote",
local是代表数据已经获取到本地从本地就能取得
remote是代表从后台服务器去取得数据。也就是你url所指定的地址去取得。


62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧