先上代码..
Ext.CopRechargeHisModiWin = Ext.extend(Ext.Window, {
xtype: "window",
width: 350,
height: 340,
frame: true,
title: '修改',
receiptType: 'asdfasdfsda',
receiptNo: '',
createForm: function() {
var modiForm = {
xtype: 'form',
bodyStyle: "padding:5px 5px 0",
frame: true,
title: "充值",
defaultType: 'textfield',
width: 350,
height: 250,
items: [
{ xtype: 'textfield', fieldLabel: '充值金额', id: 'RechargeAmount' },
{ xtype: 'combo', fieldLabel: '票据类型', id: 'ReceiptType', store: ['现金', '银行转账', '支票'], triggerAction: 'all' },
{ xtype: 'textfield', fieldLabel: '票据号码', id: 'ReceptiNo' }
]
}; return modiForm; }, subData: function() {
//this function for submit data to data source
alert('Data submit');
},
initComponent: function() {
Ext.CopRechargeHisModiWin.superclass.initComponent.call(this);
this.fp = this.createForm();
this.add(this.fp);
this.addButton('提交', this.subData, this);
this.addButton('取消', function() { this.close(); }, this);
} });
我写了一个函数来打开这个自定义window var win = new Ext.CopRechargeHisModiWin({
receiptType: '现金',
receiptNo: '50'
});
win.show();
我想把receiptType 和 receiptNo的值附到Form里面对应的位置.. 那么我应该怎 样做呢???
顺便 问多一个问题..我在做一个GridPanel
我想在这个GridPanel 做一个操作栏.. 然后 每一行数据后面都会有一个修改按钮..
当按了这个修改按钮之后, 这条数据上的某一个特定cell 就会变成textfield 而且光标会定在那里.. 有人能告诉我怎样做吗?? 我做了两周了.. 还是做不了谢谢
Ext.CopRechargeHisModiWin = Ext.extend(Ext.Window, {
xtype: "window",
width: 350,
height: 340,
frame: true,
title: '修改',
receiptType: 'asdfasdfsda',
receiptNo: '',
createForm: function() {
var modiForm = {
xtype: 'form',
bodyStyle: "padding:5px 5px 0",
frame: true,
title: "充值",
defaultType: 'textfield',
width: 350,
height: 250,
items: [
{ xtype: 'textfield', fieldLabel: '充值金额', id: 'RechargeAmount' },
{ xtype: 'combo', fieldLabel: '票据类型', id: 'ReceiptType', store: ['现金', '银行转账', '支票'], triggerAction: 'all' },
{ xtype: 'textfield', fieldLabel: '票据号码', id: 'ReceptiNo' }
]
}; return modiForm; }, subData: function() {
//this function for submit data to data source
alert('Data submit');
},
initComponent: function() {
Ext.CopRechargeHisModiWin.superclass.initComponent.call(this);
this.fp = this.createForm();
this.add(this.fp);
this.addButton('提交', this.subData, this);
this.addButton('取消', function() { this.close(); }, this);
} });
我写了一个函数来打开这个自定义window var win = new Ext.CopRechargeHisModiWin({
receiptType: '现金',
receiptNo: '50'
});
win.show();
我想把receiptType 和 receiptNo的值附到Form里面对应的位置.. 那么我应该怎 样做呢???
顺便 问多一个问题..我在做一个GridPanel
我想在这个GridPanel 做一个操作栏.. 然后 每一行数据后面都会有一个修改按钮..
当按了这个修改按钮之后, 这条数据上的某一个特定cell 就会变成textfield 而且光标会定在那里.. 有人能告诉我怎样做吗?? 我做了两周了.. 还是做不了谢谢
var win = new Ext.CopRechargeHisModiWin({
});
win.show();
Ext.get("ReceiptType").dom.value="现金";
Ext.get("ReceptiNo").dom.value="50";
});
这个可以阿.. 谢谢再追问一下. 我要从gridpanl那里取值然后附到这个form这里. 应该怎样做呢?我做了一个这样子的.~
/// <reference path="../ExtJs/vswd-ext_2.2.js" />
//
Ext.onReady(function() {
function renderDate(record) {
return eval("new " + record.substr(1, record.length - 2)).toLocaleString();
}
var data = { CropID: '1', CropName: '南方海岸科技服务有限公司', Balance: '500', Amount: '11000', MinLogBalance: '100', BalanceReminder: '1' }; var his = [{ His_id: '1', CropID: '1', CropName: '南方海岸科技服务有限公司', RechargeAmount: '500', ReceiptType: '现金', ReceptiNo: '100', operName: 'Chessman', operTime: '\/Date(1239498043171+0800)\/'}]; tpl = new Ext.XTemplate('<p>编号: {CropID} 名称: {CropName} 余额: {Balance} 充值总额: {Amount}</p>'); var store = new Ext.data.JsonStore({
data: his,
fields: ["His_id", "CropID", "CropName", 'RechargeAmount', 'ReceiptType', 'ReceptiNo', 'operName', 'operTime']
}); function oper(id) {
return '<a href="#" onclick="ModiHis();" >修改</a> ' +
'<a href="#" >充值</a> ' +
'<a href="#">充值历史纪录</a> ' +
'<a href="Cop_fee_month.aspx?id=' + id + '">账单</a>';
}; var grid = new Ext.grid.GridPanel({
store: store,
cm: new Ext.grid.ColumnModel([
{ header: '编号', width: 50, dataIndex: 'His_id' },
{ header: '公司编号', width: 50, dataIndex: 'CropID' },
{ header: '公司名称', dataIndex: 'CropName' },
{ header: '充值金额', dataIndex: 'RechargeAmount', sortable: true },
{ header: '票据类型', dataIndex: 'ReceiptType', sortable: true },
{ header: '票据号码', dataIndex: 'ReceptiNo', sortable: true, editor: { xtype: 'textfield'} },
{ header: '操作人', dataIndex: 'operName' },
{ header: '操作时间', dataIndex: 'operTime', renderer: renderDate },
{ header: '操作', dataIndex: 'His_id', renderer: oper
}
]),
width: 1280,
clicksToEdit: 0,
height: 300,
split: true,
viewConfig: { forceFit: true },
buttons: [{ text: 'A', handler: function() { var sm = grid.getSelectionModel();
sel = sm.getSelected();
alert(sel.data.CropName); }
}, { text: 'B'}],
frame: true,
title: '公司账号列表',
region: 'south' }); var RechargeHisPanel = new Ext.Panel({
renderTo: 'panel',
autoWidth: true,
autoHeight: true,
id: "mypanel",
title: "公司账号充值",
items: [{ id: 'detail',
region: 'center',
bodyStyle: {
background: '#deecfd',
padding: '7px'
},
html: 'Company details'
}, grid]
}); var detail = Ext.getCmp('detail');
tpl.overwrite(detail.body, data);
Ext.CopRechargeHisModiWin = Ext.extend(Ext.Window, {
xtype: "window",
width: 350,
height: 340,
frame: true,
title: '修改', createForm: function() {
var modiForm = {
xtype: 'form',
bodyStyle: "padding:5px 5px 0",
frame: true,
title: "充值",
defaultType: 'textfield',
width: 350,
height: 250,
items: [
{ xtype: 'textfield', fieldLabel: '充值金额', id: 'RechargeAmount' },
{ xtype: 'combo', fieldLabel: '票据类型', id: 'ReceiptType', store: ['现金', '银行转账', '支票'], triggerAction: 'all' },
{ xtype: 'textfield', fieldLabel: '票据号码', id: 'ReceptiNo' }
]
}; return modiForm; }, subData: function() {
//this function for submit data to data source
alert('Update');
},
initComponent: function() {
Ext.CopRechargeHisModiWin.superclass.initComponent.call(this);
this.fp = this.createForm();
this.add(this.fp);
this.addButton('提交', this.subData, this);
this.addButton('取消', function() { this.close(); }, this);
} });
function ModiHis() {
var sm = grid.getSelectionModel();
sel = sm.getSelected(); var win = new Ext.CopRechargeHisModiWin();
win.show();
Ext.getDom('ReceiptType').value = sel.data.ReceiptType;
Ext.getDom('ReceptiNo').value = sel.data.ReceptiNo;
}
});这样子写的话. 打开页面显示没有问题.但当我按了"修改"之后就会出错了. 网页错误详细信息消息: 缺少对象
行: 1
字符: 1
代码: 0
URI: http://localhost:10949/CompanyRechargeHistory.htm