ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值
生活随笔
收集整理的這篇文章主要介紹了
ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題重現:修改不會有問題,id會綁定之前的grid,有具體數字
添加有問題,因為id是空,傳的是綁定值的話會顯示“類名-1”,從int類型變成了string類型,后臺會出錯
這是EduQuestionBankForm的代碼
/*** @author cjy* @Date 2018/6/2 15:06.*/ Ext.define('Admin.view.eduQuestionBank.EduQuestionBankForm', {extend: 'Ext.window.Window',xtype: 'eduQuestionBankForm',title: '題庫添加',requires: ['Admin.view.eduQuestionBank.EduQuestionBankFormController','Ext.form.Panel','Ext.form.field.ComboBox','Ext.form.field.Text','Ext.form.field.TextArea','Ext.layout.container.Fit'],layout: 'fit',modal: true,height: 440,width: 500,controller: 'eduQuestionBankForm',viewModel: {links: {theEduQuestionBank: {type: 'eduQuestionBank.EduQuestionBank',create: true}},data: {roleComboQueryMode: 'remote'}},items: {xtype: 'form',id:'dictionaryF',modelValidation: true,defaults: {labelAlign: 'left',margin: 10,msgTarget: 'side'},items: [{xtype:'hidden',name:'id',id :'hiddenEduQuestionBankId',bind:{value:'{theEduQuestionBank.id}'}},{xtype: 'textfield',name: 'title',allowBlank:false,fieldLabel: '題庫名稱',bind: {value: '{theEduQuestionBank.title}'}}, {xtype: 'textfield',name: 'postType',fieldLabel: '對應崗位',allowBlank:false,bind: '{theEduQuestionBank.postType}'}, {xtype: 'textfield',name: 'createUserId',fieldLabel: '創建人',allowBlank:false,bind: '{theEduQuestionBank.createUserId}'}],buttons: [{text: '確定',handler: 'editEduQuestionBank'}, {text: '取消',handler: 'closeEduQuestionBankWindow'}]} });解決方案:
正則判斷是否是數字,是數字則找到id或者name的地方,將其禁用,就不會再向后臺發送參數了
var reg = /^\d+$/;if (!reg.test(form.form.findField('hiddenEduQuestionBankId').getValue())) {form.form.findField('hiddenEduQuestionBankId').setDisabled(true);}?
轉載于:https://www.cnblogs.com/Java-Starter/p/9133429.html
總結
以上是生活随笔為你收集整理的ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深入理解建造者模式 ——组装复杂的实例
- 下一篇: Android子线程中更新UI的4种方法