PDA

View Full Version : form.load not display data???????



GeoffreyRen
30 Jun 2010, 4:08 PM
Hi All

the following was the code:


///<reference path="../ext/vswd-ext_2.0.2.js" />
/**
* ??????.
* @class com.tsingdai.ux.Detail
*/
Ext.ns('Article');
Article.Form = Ext.extend(Ext.form.FormPanel, {
store: null
, waitMsgTarget: true
, articleID: ''
, border: false
, labelWidth: 90
, frame: true
, bodyStyle: 'padding:5px 5px 0'
, labelAlign: 'right'
, buttonAlign: 'center'
, url: '/ReportArticle/SaveOrUpdate'
/**
* ?????.
*/
, constructor: function (config) {
config = config || {};
this.store = config.store;
this.articleID = config.articleID;
Article.Form.superclass.constructor.call(this, config);
}
/**
* ?????.
*/
, initComponent: function () {
var config = {
border: false
, labelWidth: 90
, frame: true
, bodyStyle: 'padding:5px 5px 0'
, labelAlign: 'right'
, buttonAlign: 'center'
, items: [
this.getTitleColumn()
, {
layout: 'column',
items: [{
columnWidth: .5,
bodyStyle: 'padding:1px',
layout: 'form',
defaultType: 'textfield',
items: this.getFirstColumn()
}, {
columnWidth: .5,
bodyStyle: 'padding:1px',
layout: 'form',
defaultType: 'textfield',
items: this.getSecondColumn()
}]
}
, this.getContextColumn()
]
, buttons: [{
text: '??'
, formBind: true
, cls: "x-btn-text-icon"
, icon: "/Content/icons/accept.png"
, scope: this
, handler: this.submit
}, {
text: '??'
, id: 'cancelFormBtn'
, cls: "x-btn-text-icon"
, icon: "/Content/icons/door_open.png"
, scope: this
, handler: this.cancel
}]
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Article.Form.superclass.initComponent.apply(this, arguments);

}
/**
* ????.
*/
, onRender: function () {
//???????
var updateEdit = Ext.isDefined(this.articleID);
debugger;
//load????
if (updateEdit) {
var formLoadArgs = {
url: '/ReportArticle/GetArticleById'
, params: {
'Id': this.articleID
}
, waitMsg: '?????...'
};
this.reader = this.store.reader;
if (formLoadArgs) {
this.load(formLoadArgs);
}
}
// call parent
Article.Form.superclass.onRender.apply(this, arguments);
// set wait message target
//this.getForm().waitMsgTarget = this.getEl();
}
/**
* ??????.
*/
, submit: function () {
if (this.getForm().isValid()) {
this.getForm().submit({
url: this.url
, scope: this
, success: this.onSuccess
, failure: this.onFailure
, params: {
'Id': this.articleID
}
, waitMsg: '??????...'
});
}
}
, cancel: function () {
this.ownerCt.close(); // ????
}
/**
* Request????.
*/
, onSuccess: function (form, action) {
Ext.Msg.show({
title: '??'
, msg: '??????'
, modal: true
, icon: Ext.Msg.INFO
, buttons: Ext.Msg.OK
});
this.ownerCt.close(); // ????
}
/**
* Request????.
*/
, onFailure: function (form, action) {
JsHelper.ShowError(action.result.msg);
}
/*
* ???????
*/
, getTitleColumn: function () {
// ????????????
var titleColumn = {
xtype: 'textfield',
fieldLabel: '????<span style="color: red;" >*</span>',
width: 430,
name: 'Title',
allowBlank: false
};
return titleColumn;
}
/*
* ???????
*/
, getFirstColumn: function () {
// ??????????????
var firstColumn = [{
fieldLabel: '????<span style="color: red;" >*</span>',
allowBlank: false,
width: 150,
name: 'Author'
}, {
xtype: 'datefield',
fieldLabel: '????<span style="color: red;" >*</span>',
allowBlank: false,
width: 150,
name: 'RunTime'
}];
return firstColumn;
}
/*
* ???????
*/
, getSecondColumn: function () {
// ??????????????
var secondColumn = [{// ?? ??? ??????????????
fieldLabel: '???<span style="color: red;" >*</span>',
width: 150,
name: 'KeyWords',
allowBlank: false,
plugins: [Ext.ux.plugins.RemoteValidator]
}, {
fieldLabel: '????<span style="color: red;" >*</span>',
width: 150,
name: 'PublishDep',
allowBlank: false
}];
return secondColumn;
}
/*
* ???????
*/
, getContextColumn: function () {
//????
var contextColumn = {
fieldLabel: '????',
name: 'Context',
value: '',
anchor: '100%',
xtype: "htmleditor",
height: 300,
plugins: [
//new Ext.ux.HTMLEditorStyles([{name: "Section Heading", value: "section_head"}]),
new Ext.ux.HtmlEditor.ButtonImage(),
new Ext.ux.form.HtmlEditor.Word(),
new Ext.ux.form.HtmlEditor.Divider(),
new Ext.ux.form.HtmlEditor.Table(),
new Ext.ux.form.HtmlEditor.HR(),
new Ext.ux.form.HtmlEditor.IndentOutdent(),
new Ext.ux.form.HtmlEditor.SubSuperScript(),
new Ext.ux.form.HtmlEditor.RemoveFormat()
]
};
return contextColumn;
}
});
Ext.reg('articleform', Article.Form);


I use the firebug tracks the response. the following was the json text:



{ "data": [ { "Id": "b887bd6e-5969-4643-a26b-9a08e16870e2", "Version": 1, "Title": "dfsdsf", "RunTime": new Date( 1276704000000 ), "KeyWords": "sdfsd", "Context": "sdfsadfdsfdsf", "PublishDep": "sdfsdfs", "Status": 0, "CreateTime": new Date( 1277836168000 ), "ModifyTime": new Date( 1277836168000 ), "IsDelete": false, "Author": "dsfdsf", "Attaches": [] } ]}the form didn't render the data in field.

4 Jul 2010, 9:00 AM
I have no idea why people use data stores for one record of data. Seems silly if you ask me!

That said, are you loading your store? do you have a reader configured for the form? Do you see the Ajax request being fired? Do have the store's "fields" matched with the form's field names?