惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - tubo

依赖Asp.net Core的类库 找一款可以插入数学公式的思维导图软件 联想个人云开启Docker并安装常用的Docker 联想个人云无损开启SSH 我只想在Windows Server 2019上build 基于Linux的Docker Gerrit 添加用户 Windows 10 安装过程中,在自定义登录页面进入审核模式 mac远程桌面连接windows 8.1 update,提示: 远程桌面连接无法验证您希望连接的计算机的身份 iOS开发点滴:iPhone屏幕适配 C# Winform中如何让PictureBox的背景透明 ExtJS扩展:扩展grid Extjs扩展:封装Plupload 用NuGet管理程序包时,如果解决方案目录下的packages文件夹中某一个程序包存在2个以上的版本,则会提示错误 User Profile Service服务未登录,无法加载用户配置文件 可动态构造查询条件的表达式类库(1) Windows 8安装杀毒软件avast后,不能用Sysprep进行通用化封装 Nuget 启用数据库迁移的时候一定要把包含DbContext的项目设为启动项目 “PostSharp21”任务意外失败 为什么TFS会自动签出解决方案文件(.sln)?
ExtJS扩展:扩展grid之toolbar button禁用表达式
tubo · 2013-11-12 · via 博客园 - tubo

      在前一篇文章我们扩展了grid通过选中记录数来禁用toolbar上的按钮,有时候我们需要通过记录中的数据来决定是否禁用按钮,今天我们就来扩展它。

      照例,最新的代码和例子都在github上:ExtJsExtend

      先看看使用代码(这里只有部分代码,可以结合前一篇文章来阅读或者直接通过github获取最新代码):

 
                buttonDisable: { 
                    noSelection: ['Edit', 'Delete', 'Print'], 
                    moreSelections: ['Edit'], 
                    expressions: { 
                        Edit: '$phone == "555-222-1254"' 
                    } 
                },

     (这里重构了前一篇文章中的用法困惑,将noSelectionDisable、oneSelectionDisable、moreSelectionsDisable整合进buttonDisable中了)。

      expressions就是表达式,用item的name或itemId作为Key,表达式就是javascript的表达式,需要注意的是要在field的名称前加$(因为最终要替换$,通过eval来运行表达式)。来看看效果:

image

嗯,这条记录是可以编辑的。

image

这条记录不能编辑,因为phone== “555-222-1254”。

看看这部分扩展的代码:

 
            if (me.buttonDisable.expressions) { 
                var exps = me.buttonDisable.expressions; 
                for (var btn in exps) { 
                    var exp = exps[btn]; 
                    for(var i = 0, il = records.length;i<il;i++) { 
                        var data = records[i].data; 
                        exp = exp.replace(/\$/g, 'data.'); 
                        var disabled = eval(exp); 
                        if (disabled === true) { 
                            disables[btn] = true; 
                            break; 
                        } 
                    } 
                } 
            }

代码也比较简单,就是遍历选中记录,然后在数据上执行表达式,如果为true就禁用,只要有一条记录的数据满足,那么这个按钮就将会被禁用。

还需注意,表达式禁用比选中记录数禁用的优先级高。