ExtJs
'/RHSite/manager/Article)queryForId?id=186'
地址获取的值为:
{success:true,data:[{id:186,title:'标题4'}]}
Ext.onReady(function(){
/****************************************/
/* 主窗体 */
/****************************************/
/****组件****/
/****数据源****/
/****初始化****/
/****事件****/
/*----------------------------------------------------------------------------------------------------------------------*/
var articleClsStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleClassify)list'
}) }); var articleSpcStore = new Ext.data.Store({
autoLoad:true,
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',
root:'root',
fields:[
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleSpecail)list'
})
});
Ext.AddArticleWin=Ext.extend(Ext.Window ,{
xtype:"window",
title:"文章管理 - 添加",
width:800,
height:700,
modal:true,
animCollapse:true,
animateTarget:'articleGrid',
bodyStyle:'padding:10px,10px,10px,10px;',
initComponent: function(){
Ext.AddArticleWin.superclass.initComponent.call(this);
}
}) Ext.AddArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
name:'article',
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
reader: new Ext.data.JsonReader(
{success:'success',root:'data'},
[{name: 'article.id',mapping:'article.id'},
{name: 'article.title',mapping:'article.title',type:'string'}
]),
initComponent: function(){
this.items=[
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.id',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
forceSelection : true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
forceSelection : true
},{
hiddenName:'article.overTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"我的按钮",
handler:addArticleEvent
}
],
Ext.AddArticleForm.superclass.initComponent.call(this);
}
})
function addArticleEvent(){
addArticleForm.getForm().submit({
waitMsg: '正在提交数据...',
waitTitle: '提示',
method: 'post',
url:'/RHSite/manager/Article)add',
success: function(form, action) {
var flag=action.result.success;
Ext.Msg.alert('提示',flag);
if(flag == '提交成功'){
Ext.Msg.alert('提示',flag);
}
},
failure: function(form, action) {
Ext.Msg.alert('错误', action.result.error);
}
})
}
var loadFormData = function() {
addArticleForm.form.load( {
method:'get',
url : '/RHSite/manager/Article)queryForId?id=186',
waitMsg : '正在载入数据...',
success : function(form,action) {
Ext.Msg.alert("load", action.response.responseText);
},
failure : function(form,action) {
}
});
};
var addArticleWin = new Ext.AddArticleWin({});
var addArticleForm = new Ext.AddArticleForm({});
addArticleWin.add(addArticleForm);
loadFormData();
addArticleWin.show();
var fckobj = new FCKeditor('article.mainContent', "100%", "500px");
fckobj.ToolbarSet = 'Default';
fckobj.ReplaceTextarea();
})
但数据无法填充到FORM中
求高手求解。
'/RHSite/manager/Article)queryForId?id=186'
地址获取的值为:
{success:true,data:[{id:186,title:'标题4'}]}
Ext.onReady(function(){
/****************************************/
/* 主窗体 */
/****************************************/
/****组件****/
/****数据源****/
/****初始化****/
/****事件****/
/*----------------------------------------------------------------------------------------------------------------------*/
var articleClsStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleClassify)list'
}) }); var articleSpcStore = new Ext.data.Store({
autoLoad:true,
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',
root:'root',
fields:[
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleSpecail)list'
})
});
Ext.AddArticleWin=Ext.extend(Ext.Window ,{
xtype:"window",
title:"文章管理 - 添加",
width:800,
height:700,
modal:true,
animCollapse:true,
animateTarget:'articleGrid',
bodyStyle:'padding:10px,10px,10px,10px;',
initComponent: function(){
Ext.AddArticleWin.superclass.initComponent.call(this);
}
}) Ext.AddArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
name:'article',
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
reader: new Ext.data.JsonReader(
{success:'success',root:'data'},
[{name: 'article.id',mapping:'article.id'},
{name: 'article.title',mapping:'article.title',type:'string'}
]),
initComponent: function(){
this.items=[
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.id',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
forceSelection : true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
forceSelection : true
},{
hiddenName:'article.overTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"我的按钮",
handler:addArticleEvent
}
],
Ext.AddArticleForm.superclass.initComponent.call(this);
}
})
function addArticleEvent(){
addArticleForm.getForm().submit({
waitMsg: '正在提交数据...',
waitTitle: '提示',
method: 'post',
url:'/RHSite/manager/Article)add',
success: function(form, action) {
var flag=action.result.success;
Ext.Msg.alert('提示',flag);
if(flag == '提交成功'){
Ext.Msg.alert('提示',flag);
}
},
failure: function(form, action) {
Ext.Msg.alert('错误', action.result.error);
}
})
}
var loadFormData = function() {
addArticleForm.form.load( {
method:'get',
url : '/RHSite/manager/Article)queryForId?id=186',
waitMsg : '正在载入数据...',
success : function(form,action) {
Ext.Msg.alert("load", action.response.responseText);
},
failure : function(form,action) {
}
});
};
var addArticleWin = new Ext.AddArticleWin({});
var addArticleForm = new Ext.AddArticleForm({});
addArticleWin.add(addArticleForm);
loadFormData();
addArticleWin.show();
var fckobj = new FCKeditor('article.mainContent', "100%", "500px");
fckobj.ToolbarSet = 'Default';
fckobj.ReplaceTextarea();
})
但数据无法填充到FORM中
求高手求解。
解决方案 »
- 各位大哥帮帮忙、很急!
- AJAX 问题。
- jQuery给select添加option时,FireFox中可以执行,IE里不行?
- 请教javascript的新手问题
- 一直没有解决的问题?高手指点 每天看都没有人回答 好可怜
- vml生成的图片导入word 怎么导阿〉? 求救!
- 一个简单的正则表表达式,如何让/^\d+\.\d{2}$/可以包含空格?
- 急!我在WEB页面中插了一个控件,怎样设置它的属性?
- 方法的枚举?????
- Javascript中的精度问题?为什么45.6*13=592.8000000000001,而86217.8+45.6=86263.40000000001??
- ExtJs 表单数据填充异常,求解~~~~
- 论坛的群众。版主们能给力点吗?如何禁止拉动浏览器大小!
reader定义是{name: 'article.id',mapping:'article.id'},
{name: 'article.title',mapping:'article.title',type:'string'}
这也对应不上啊,肯定取不到数据。
Ext.onReady(function(){
/****************************************/
/* 主窗体 */
/****************************************/
/****组件****/
/****数据源****/
/****初始化****/
/****事件****/
/*----------------------------------------------------------------------------------------------------------------------*/
var articleClsStore = new Ext.data.Store({
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',//分页时需要的参数
root:'root',//json格式的根节点
fields:[ //在数据库中映射的字段名
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
//发送请求得到以上数据
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleClassify)list'
}) }); var articleSpcStore = new Ext.data.Store({
autoLoad:true,
reader:new Ext.data.JsonReader({
totalRecords:'totalCount',
root:'root',
fields:[
{name:'id',type:'int'},
{name:'name',type:'String'}
]
}),
proxy:new Ext.data.HttpProxy({
url:'/RHSite/manager/ArticleSpecail)list'
})
});
Ext.AddArticleWin=Ext.extend(Ext.Window ,{
xtype:"window",
title:"文章管理 - 添加",
width:800,
height:700,
modal:true,
animCollapse:true,
animateTarget:'articleGrid',
bodyStyle:'padding:10px,10px,10px,10px;',
initComponent: function(){
Ext.AddArticleWin.superclass.initComponent.call(this);
}
}) Ext.AddArticleForm=Ext.extend(Ext.form.FormPanel ,{
xtype:"form",
name:'article',
title:'',
labelWidth:100,
labelAlign:"left",
layout:"form",
width:'100%',
bodyStyle:'padding:5px,5px,5px,5px;',
reader: new Ext.data.JsonReader(
{success:'success',root:'data'},
[{name: 'article.id',mapping:'article.id'},
{name: 'article.title',mapping:'article.title'}
]),
initComponent: function(){
this.items=[
{
name:'article.title',
xtype:"textfield",
fieldLabel:"标题",
anchor:"90%"
},
{
name:'article.id',
xtype:"textfield",
fieldLabel:"关键字",
anchor:"70%"
},
{
hiddenName:'article.classify.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"分类",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleClsStore,
valueField : "id",
displayField : "name",
forceSelection : true
},
{
hiddenName:'article.special.id',
xtype:"combo",
triggerAction:"all",
fieldLabel:"专题",
loadingText:"正在加载数据...",
anchor:"50%",
store : articleSpcStore,
valueField : "id",
displayField : "name",
forceSelection : true
},{
hiddenName:'article.overTime',
xtype:"datefield",
fieldLabel:"有效时间",
anchor:"50%",
format: 'Y-m-d H:i:s'
},{
name:'article.mainContent',
xtype:"textarea",
anchor:"90%",
fieldLabel:"内容",
height:600,
width:450
},{
xtype:"button",
text:"我的按钮",
handler:addArticleEvent
}
],
Ext.AddArticleForm.superclass.initComponent.call(this);
}
})
function addArticleEvent(){
addArticleForm.getForm().submit({
waitMsg: '正在提交数据...',
waitTitle: '提示',
method: 'post',
url:'/RHSite/manager/Article)add',
success: function(form, action) {
var flag=action.result.success;
Ext.Msg.alert('提示',flag);
if(flag == '提交成功'){
Ext.Msg.alert('提示',flag);
}
},
failure: function(form, action) {
Ext.Msg.alert('错误', action.result.error);
}
})
}
var loadFormData = function() {
addArticleForm.getForm().load( {
method:'post',
url : '/RHSite/manager/Article)queryForId?id=186',
waitMsg : '正在载入数据...',
success : function(form,action) {
Ext.Msg.alert("load", action.response.responseText);
},
failure : function(form,action) {
}
});
};
var addArticleWin = new Ext.AddArticleWin({});
var addArticleForm = new Ext.AddArticleForm({});
addArticleWin.add(addArticleForm);
loadFormData();
addArticleWin.show();
// var fckobj = new FCKeditor('article.mainContent', "100%", "500px");
// fckobj.ToolbarSet = 'Default';
// fckobj.ReplaceTextarea();
})
返回的数据为:
{success:true,data:[{'article.id':186,'article.title':'标题4'}]}但表单依然无显示
{'article.id':186,'article.title':'标题4'}
var o={success:true,data:[{'article.id':186,'article.title':'标题4'}]};
addArticleForm.getForm().setValues(o.data[0]);
{success:'success',root:'data'},//此处的设置
[{name: 'article.id',mapping:'article.id'},
{name: 'article.title',mapping:'article.title'}
]),
1.还有var o是从哪里获取的?
2.如上设置,当我把success:true,去除后,程序就是显示
failure : function(form,action) {
}
到失败的处理里去了。