extjs vtype:使用同一行中的另一个值检查值
我有一个 Ext.grid.Panel,我想验证用户输入:有一个名为 delete
的字段和一个名为 string
的字段。 delete
的有效输入是一个数字,该数字不能大于同一行中string
字段的长度。我已经知道如何使用 vtype
所以现在我
delete : function(val, field){
var expr = new RegExp("^[-]?[0-9]*[\.]?[0-9]*$");
var num = expr.test(val);
if (!num) return false; //can't be not a number
else{
//have no idea...
}
}
不知道如何访问同一行的 string
值。
希望它很清楚。谢谢!
I have an Ext.grid.Panel
and i want to validate user input: there is a field named delete
and a field named string
. Valid input for delete
is a number, which can't be greater than the length of a string
field in the same row. I already know how to use vtype
so now i have
delete : function(val, field){
var expr = new RegExp("^[-]?[0-9]*[\.]?[0-9]*$");
var num = expr.test(val);
if (!num) return false; //can't be not a number
else{
//have no idea...
}
}
I have no idea how to access string
value for the same row.
Hope it's quite clear. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果将编辑器定义为变量,实际上会更简单、更清晰,您只需在字段验证器方法中引用它并获取活动记录,例如:
It's actually much simpler and cleaner if you define your editor as a variable, you can just refer to it in the fields validator method and get the active record, for example:
您应该处理
validateedit( Ext.grid.plugin.Editing editor, Object e, Object eOpts )
事件。第二个参数
e
包含对已编辑记录 (e.record
) 的引用。您可以使用此记录来获取两个字段(string
和delete
)并相应地执行验证。将
false
分配给e.cancel
将取消编辑。You should handle
validateedit( Ext.grid.plugin.Editing editor, Object e, Object eOpts )
event.The second argument,
e
, contains reference to the record that is edited (e.record
). You could use this record to get both fields(string
anddelete
) and perform validation accordingly.Assigning
false
toe.cancel
will cancel the editing.好吧,有一个解决方法,但它很丑陋:
well, there's a workaround, but it's ugly:
我通过以下方式访问该插件:
这使您可以访问 cellEditing 插件,从那里您可以执行以下操作:
I accessed the plugin the following way:
That gives you access to the cellEditing plugin and from there you could do a: