Extjs4 中的 setRenderer() 方法
Extjs 3.3.1
有方法 setRenderer()
现在
/**
* Sets the rendering (formatting) function for a column.
*/
setRenderer( Number col, Function fn ) : void
我在 ExtJS 4
的 setRenderer
中没有得到任何方法代码>.那么如何在 ExtJS 4 中运行时格式化网格列。
Extjs 3.3.1
have the method setRenderer()
as
/**
* Sets the rendering (formatting) function for a column.
*/
setRenderer( Number col, Function fn ) : void
Now I don't get any method in ExtJS 4
of setRenderer
. So How can I format grid column at runtime in ExtJS 4
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您创建网格时,您可以在每一列上定义渲染器...
然后您可以在全局范围内定义您的函数...
When you're creating your grid you can define the renderer on each column...
And then you can define your function in a global scope...
我所做的是事后设置渲染器。在我的应用程序启动后,我获得了实例化的组件,并在控制器的 onLaunch() 函数中添加了一个渲染器,如下所示:
我喜欢这种方法的原因是因为我能够将渲染器函数放入我的控制器中并将逻辑保留在我的视图之外。它帮助我更好地组织我的代码。
What I did was set the renderer after the fact. After my application launched, I got the instantiated component and added a renderer in my controller's onLaunch() function like this:
The reason I like this method is because I am able to put the renderer functions in my controller and keep logic out of my view. It helps me organize my code better.
看起来在传递 sencha 论坛上的这篇文章。
您可以使用网格的重新配置方法< /a> 交换不同的列列表(以及渲染器),但这确实有一个主要缺点,您必须完全重新指定整个列。
你找到更好的方法了吗?我真的不喜欢这样的事实:它迫使您将渲染器放在无法测试且无法以非静态方式访问状态的地方。
然而,在这种情况下,治疗似乎比疾病更糟糕,因为您最终会将非常明确的视图代码从视图中删除。
有时感觉他们并没有真正考虑过这些东西的设计:(
it looks like the the way to do it is mentioned in passing in this post on the sencha forum.
You can use a grid's reconfigure method to swap in a different list of columns (along with renderers) however this does have the major downside that you'll have to totally respecify the columns in their entirety.
Did you find a better way? I really dont like the fact it forces you to put renderers in a place where they can't be tested and can't access state in a none static way.
However it seems the cure is worse than the disease in this case as you'd end up taking what is very definitely view code out of the view.
Sometimes it feels like they didn't really think about the design of these things very much :(