各位好。我的项目前台用的是extjs,后台是struts2+Spring+mybatis。我在界面上有个查询按钮,一点查询会将条件传递给后台,后台根据条件从数据库中找到相应的数据,并返回给前台。
下边是我的form
- JScript code
function LoadForm(baseUrl) { var fpProductSearch = new Ext.FormPanel({ renderTo: 'searchDiv', id:"fpProductSearch", labelWidth: 75, frame:true, title: '产品搜索', bodyStyle:'padding:5px 5px 0', width: 350, defaults: {width: 230}, defaultType: 'textfield', items: [{ fieldLabel: '产品名称', emptyText:'B-5538(YAS023400)', name: 'product.productname' }], buttons: [{ id:"btnSearch", text: '查找', handler: function(){ var baseParams = fpProductSearch.form.getValues(); fpProduct.getForm().reset(); Ext.Ajax.request({ url : baseUrl + '/productAction!SearchProduct', method:"post", params: baseParams, success: function (response,options) { obj = Ext.decode(response.responseText); if(obj.success) { fpProduct.getForm().setValues(obj.message); }else { Ext.Msg.alert('错误', obj.message); } }, failure: function(response,options) { Ext.Msg.alert('错误', response.statusText); } }); } },{ id:"btnSReset", text: '清空', handler: function(){ fpProductSearch.getForm().reset(); } }] });var fpProduct = new Ext.FormPanel({ renderTo: 'resultDiv', labelAlign: 'top', frame:true, title: '产品信息编辑', bodyStyle:'padding:5px 5px 0', width: 960, items: [{ layout:'column', items:[{ columnWidth:.25, layout: 'form', items: [{ xtype:'textfield', fieldLabel: '产品名称', name: 'productname', anchor:'95%' }, { xtype:'textfield', fieldLabel: '创建人', name: 'creator', anchor:'95%' } , { xtype:'textfield', fieldLabel: '客户', name: 'customeruid', anchor:'95%' } , { xtype:'textfield', fieldLabel: '拼板数量', name: 'panelnum', anchor:'95%' } , { xtype:'textfield', fieldLabel: '备注', name: 'description', anchor:'95%' }] },{ columnWidth:.25, layout: 'form', items: [{ xtype:'textfield', fieldLabel: '物料号', name: 'productpartnumber', anchor:'95%' },{ xtype:'textfield', fieldLabel: '创建时间', name: 'createDateStr', anchor:'95%' }, { xtype:'textfield', fieldLabel: '位号图', name: 'drawuid', anchor:'95%' }, { xtype:'textfield', fieldLabel: 'B面点数', name: 'bottomplaneqty', anchor:'95%' }, { xtype:'combo', fieldLabel: '状态', store:productStatusStore, name: 'productstatus', hiddenName:'productstatus', mode : 'local', valueField: 'accountType', displayField: 'accountTypeName', triggerAction: "all", editable:false, anchor:'95%' }] } ,{ columnWidth:.25, layout: 'form', items: [{ xtype:'textfield', fieldLabel: '版本', name: 'productversion', anchor:'95%' },{ xtype:'textfield', fieldLabel: '最后修改人', name: 'modifier', anchor:'95%' }, { xtype:'textfield', fieldLabel: '工艺', name: 'proroutinguid', anchor:'95%' }, { xtype:'textfield', fieldLabel: 'T面点数', name: 'topplaneqty', anchor:'95%' }] } ,{ columnWidth:.25, layout: 'form', items: [{ xtype:'textfield', fieldLabel: '产品型号', name: 'productcode', anchor:'95%' },{ xtype:'textfield', fieldLabel: '最后修改时间', name: 'updateDateStr', anchor:'95%' }, { xtype:'textfield', fieldLabel: 'BOM', name: 'bomuid', anchor:'95%' }, { xtype:'textfield', fieldLabel: '变更号', name: 'ecn', anchor:'95%' }] }] }], buttons: [{ text: '提交', handler: function(){ var pros=fpProduct.form.getValues(); Ext.Ajax.request({ url : baseUrl + '/productAction!UpdateProduct', params: pros, success: function (response, option) { obj = Ext.decode(response.responseText); fpProduct.getForm().setValues(obj); }}) } },{ text: '清空', handler: function(){ fpProduct.getForm().reset(); } }] }); }