[英]How can I fire the property change event immediately after the property is changed?
I have this code that you can test here :我有这个代码,你可以在这里测试:
Ext.application({
name: 'Fiddle',
launch: function() {
Ext.create('Ext.grid.property.Grid', {
id: "PROPERTIES",
renderTo: Ext.getBody(),
autoHeight: true,
width: 300,
viewConfig: {
forceFit: true,
scrollOffset: 2 // the grid will never have scrollbars
},
listeners: {
propertychange: function(source, recordId, value, oldValue) {
alert("new Value=" + value);
}
},
source: {
"title": "My Object",
"color": Ext.Date.parse('10/15/2006', 'm/d/Y'),
"Available": false,
"Version": 0.01,
"Description": "A test object"
}
});
}
});
When I change the false value to true in the example the property change event only fires when I click off the true/false box.当我在示例中将 false 值更改为 true 时,仅当我单击 true/false 框时才会触发属性更改事件。 I would like the event (or another event) to fire immediately after I change the value.
我希望在更改值后立即触发事件(或其他事件)。 How can I do this?
我怎样才能做到这一点?
This is the way it works, your field will only fire the propertychange event once the editor is closed.这是它的工作方式,您的字段只会在编辑器关闭后触发 propertychange 事件。
If you really want to run a function or do something else for every field change value before the editor is closed you will have to add a controller and listen for the change event for each field inside the property panel.如果您真的想在编辑器关闭之前为每个字段更改值运行一个函数或执行其他操作,您将必须添加一个控制器并监听属性面板中每个字段的更改事件。 Here is how it would work:
这是它的工作原理:
Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'propertygrid field': {
change: function(field, newValue, oldValue, eOpts){
console.log(field, newValue, oldValue);
}
}
});
}
});
Ext.application({
name: 'MyApp',
controllers : ['MyController'],
launch: function() {
Ext.create('Ext.grid.property.Grid', {
id: "PROPERTIES",
renderTo: Ext.getBody(),
autoHeight: true,
width: 300,
viewConfig: {
forceFit: true,
scrollOffset: 2 // the grid will never have scrollbars
},
listeners: {
propertychange: function(source, recordId, value, oldValue) {
alert("new Value=" + value);
}
},
source: {
"title": "My Object",
"color": Ext.Date.parse('10/15/2006', 'm/d/Y'),
"Available": false,
"Version": 0.01,
"Description": "A test object"
}
});
}
});
Here is a fiddle with a demo: https://fiddle.sencha.com/#fiddle/bti这是一个带有演示的小提琴: https : //fiddle.sencha.com/#fiddle/bti
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.