gpt4 book ai didi

button - 如何将X放在文本字段中以清除extjs中的文本

转载 作者:行者123 更新时间:2023-12-04 05:07:43 25 4
gpt4 key购买 nike

我想在文本字段(文本字段右侧的x)内实现一个X按钮,以清除输入的文本。我已经看到许多具有此功能的extjs应用程序。我该怎么做呢?任何建议或评论将不胜感激...
谢谢

看起来像这样...

最佳答案

您必须使用 Ext.form.field.Trigger 。这是一个例子

Ext.define('Ext.ux.CustomTrigger', {
extend: 'Ext.form.field.Trigger',
alias: 'widget.customtrigger',
initComponent: function () {
var me = this;

me.triggerCls = 'x-form-clear-trigger'; // native ExtJS class & icon

me.callParent(arguments);
},
// override onTriggerClick
onTriggerClick: function() {
this.setRawValue('');
}
});

Ext.create('Ext.form.FormPanel', {
title: 'Form with TriggerField',
bodyPadding: 5,
width: 350,
renderTo: Ext.getBody(),
items:[{
xtype: 'customtrigger',
fieldLabel: 'Sample Trigger',
emptyText: 'click the trigger'
}]
});

为了便于测试,以下是 JSFiddle

关于button - 如何将X放在文本字段中以清除extjs中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13586749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com