---
title: "Ext中FormPanel控件自动填充表单"
author: "gu0600402203"
date: "2015-01-25T19:28:50Z"
tags: []
categories: ["Web前端"]
slug: "ext-formpanel"
draft: false
lastmod: "2015-01-25T19:30:27Z"
id: 2179479
url: "https://gwm.iteye.com/blog/2179479"
---

向FormPanel中的自动填充表单赋值共有三种方法：

1、利用URL的方案：

```
form1.form.load( {
	url : EDIT_ACTION_URL+'?sid='+ _record.get('id'),
	waitMsg : '正在载入数据...',
	success : function(form,action) {
		Ext.example.msg('编辑', '载入成功！');
	},
	failure : function(form,action) {
		Ext.example.msg('编辑', '载入失败');
	}
});
```

 

2、利用store中的Record进行填充：

```
var record=sm.getSelected();
winform.getForm().loadRecord(record);
```

 

3、利用dwr获取对象后进行填充：

```
zzcParitionController.getRecordById(data.partitionid,function(paritiondata){
	winform.getForm().setValues(paritiondata);
})
```

paritiondata为json对象：{id:'xxxx',name:'dddsd',address:'cccccc'} 

java:

```
public ZzcParition getRecordById(String id){
	return this.getZzcParitionService().getParitionById(id);
}
```