ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值
生活随笔
收集整理的這篇文章主要介紹了
ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
問題重現(xiàn):修改不會(huì)有問題,id會(huì)綁定之前的grid,有具體數(shù)字
添加有問題,因?yàn)閕d是空,傳的是綁定值的話會(huì)顯示“類名-1”,從int類型變成了string類型,后臺(tái)會(huì)出錯(cuò)
這是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: '對(duì)應(yīng)崗位',allowBlank:false,bind: '{theEduQuestionBank.postType}'}, {xtype: 'textfield',name: 'createUserId',fieldLabel: '創(chuàng)建人',allowBlank:false,bind: '{theEduQuestionBank.createUserId}'}],buttons: [{text: '確定',handler: 'editEduQuestionBank'}, {text: '取消',handler: 'closeEduQuestionBankWindow'}]} });解決方案:
正則判斷是否是數(shù)字,是數(shù)字則找到id或者name的地方,將其禁用,就不會(huì)再向后臺(tái)發(fā)送參數(shù)了
var reg = /^\d+$/;if (!reg.test(form.form.findField('hiddenEduQuestionBankId').getValue())) {form.form.findField('hiddenEduQuestionBankId').setDisabled(true);}?
轉(zhuǎn)載于:https://www.cnblogs.com/Java-Starter/p/9133429.html
總結(jié)
以上是生活随笔為你收集整理的ExtJs6解决添加和修改Form共用一个form的隐藏域的id的取消传值的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深入理解建造者模式 ——组装复杂的实例
- 下一篇: Android子线程中更新UI的4种方法