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

shixixi1987 2010-03-24 11:06:25
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);
}
}
}
下拉框得不到数据,请问这段代码哪里有错误?
...全文
725 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Style123111 2011-01-09
  • 打赏
  • 举报
回复
我也遇到了数据无法显示到Combox中的情况,请问楼主解决了吗,能否告知一下具体的解决方法~谢谢了~~
asdujiayong 2010-03-25
  • 打赏
  • 举报
回复
返回的应当是json格式的而不是string 类型的
kc8886 2010-03-24
  • 打赏
  • 举报
回复
这就是了 不是js的问题 是你后台的问题 首先 getDepartment.aspx 这个地址是不是你要请求的那个地址 我不懂.net 不知道这句话HttpContext.Current.Response.Write(result);
是否可以把字符串输出到页面
shixixi1987 2010-03-24
  • 打赏
  • 举报
回复
没有数据返回
kc8886 2010-03-24
  • 打赏
  • 举报
回复
代码应该没有问题 确定store里面有数据吗?
加这句试试看有没有数据返回
dstore.load({callback:function(){
alert("Test the return record num", "共获得" + dstore.getCount() + "条数据");
}});
lin364653705 2010-03-24
  • 打赏
  • 举报
回复
 if (!IsPostBack)
{
string result = null;
result = "{rows:[{'Name':'开发部', 'Code':'1'}, {'Name':'销售部', 'Code':'2'}, {'Name':'行政部', 'Code':'3'}, {'Name':'质检部', 'Code':'4'}]}";
}


http://www.cnblogs.com/Guzenyin/archive/2008/11/08/1329610.html这里去看下吧!
kc8886 2010-03-24
  • 打赏
  • 举报
回复
没错 .net 里是这样输出到页面的
Response.Write("{success:'false',msg:'增加人员失败!'}");
这样应该没错
Response.Write(result);
kc8886 2010-03-24
  • 打赏
  • 举报
回复
Response.Write(result);
试试 这个俺就无能为力了 .net俺不会
shixixi1987 2010-03-24
  • 打赏
  • 举报
回复
各位:我想请问一下如何使用EXTjs3.1中的jsonstore获取到asp.net服务器端的数据并在combobox中显示出来。我自己反反复复测试好多遍都不行,调试时,url所指定的页面有被调用,可就是没结果。js源码与asp.net页面源码如下,请各位高手指点!谢谢!
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);
}
}
}
shixixi1987 2010-03-24
  • 打赏
  • 举报
回复
不能输出
内容概要:本文围绕双机并联虚拟同步发电机(VSG)在微电网中的功率分配、黑启动及预同步控制展开深入研究,重点提出了一种结合惯量与阻尼协同自适应控制的策略,以提升微电网在孤岛与并网模式下的频率稳定性及动态响应性能。通过Simulink搭建双VSG并联系统仿真模型,系统实现了有功/无功功率均分、微电网黑启动过程模拟、并网前的预同步控制,并引入虚拟阻抗技术以优化环流抑制。研究涵盖控制策略设计、系统建模、参数整定与仿真验证全过程,旨在增强微电网运行的可靠性、稳定性和自主恢复能力。; 适合人群:具备电力系统、微电网、电力电子及自动控制等相关专业知识,从事新能源发电、分布式能源系统、VSG控制技术等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握双机VSG并联系统的建模与仿真方法;②深入理解微电网黑启动机制与预同步控制的实现流程;③研究VSG惯量-阻尼自适应调控对系统频率稳定性和动态性能的影响;④为构网型储能、微电网能量管理系统及VSG控制器的设计与优化提供可靠的仿真验证平台。; 阅读建议:建议结合Simulink仿真模型同步学习,重点关注VSG控制环路、虚拟阻抗设计及预同步逻辑的实现细节;在复现过程中应逐步调试各功能模块,理解黑启动与预同步的时序逻辑,并通过改变负载、线路参数或初始频率偏差等方式验证系统的鲁棒性与适应性。

52,780

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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