Delayed Listener Bug - Ext JS

本文讨论了使用ExtJS框架中Grid组件的自动调整列宽功能时遇到的问题及解决办法。具体介绍了如何正确地将自定义函数作为加载事件的回调,并确保作用域设置正确。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

My Code:

ds.on('load', foo, this, {delay: 250});

Bug:

h has no properties
(ext-all.js : line 18) - Ext.util.Observable
Reply With Quote
  #2  
Old 02-21-2007, 01:30 PM
Default

Are you sure foo exists? That message means your handler function is undefined.

I just tested it locally and it worked as expected. When I passed in an undefined handler function, I got the same message as you.
Reply With Quote
  #3  
Old 02-21-2007, 02:02 PM
Default

ok i get it..

I tried doing this and didnt work:
ds.on('load', plantGrid.getView().autoSizeColumns(), this, {delay: 250});

the reason why i was trying to do it this way was because when you put autoSizeColumns in the the configuration of the grid.. it loads to fast and doesn't size properly.

it works now without the delay by doing this:

ds.on('load', adjustGrid, this, {delay: 250});

function adjustGrid(){
plantGrid.getView().autoSizeColumns();
}
Reply With Quote
  #4  
Old 02-21-2007, 02:09 PM
Default

The problem is you are executing the function immediately (you have "()" at the end) rather than passing a callback. Also, your scope with be wrong. Here's your original code edited:

var view = plantGrid.getView();
ds.on('load', view.autoSizeColumns, view, {delay: 250});

Here we are passing a function (rather than calling the function) and we are setting the scope to the "view" object so that within autoSizeColumn the this reference with be correct.
Reply With Quote
  #5  
Old 02-21-2007, 02:15 PM
Default

NICE!!!..

I never looked at it way. It works perfectly.

THANKS!!

Will be tipping you soon.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值