[英]Get all elements of a specific type using ExtJS
Hello I have been using JQuery for quite a while. 您好我已经使用JQuery很长一段时间了。 I need to get the ids of the checked elements. 我需要获取已检查元素的ID。 I have all my checkboxes as rows sitting inside a container, and I want to get the ids of all the checkboxes that have are checked. 我将所有复选框都设置为容器内的行,并且我想获取所有已选中复选框的ID。
I would use 我会用
$("#container input:checkbox")
to get all the checkboxes in that container, and then would check for which ones have been checked. 获取该容器中的所有复选框,然后检查已检查的那些复选框。
To do the same in ExtJS, i have been using the "get" method, and would do a 为了在ExtJS中做同样的事情,我一直在使用“get”方法,并且会做一个
Ext.get('input')
which gives me all the input items, but I still have to check if they are of type "checkbox", is there a way I could get only the checkbox elements from DOM? 它给了我所有输入项,但我仍然要检查它们是否是“复选框”类型,有没有办法我只能从DOM中获取复选框元素?
The equivalent function to JQuery's selector would be either Ext.query
, or Ext.DomQuery.selectNode
. 与JQuery的选择器等效的函数可以是Ext.query
,也可以是Ext.DomQuery.selectNode
。
Ext.Query
works in a very similar way as JQuery ( see how the selectors work here ). Ext.Query
以与JQuery非常相似的方式工作 ( 请参阅选择器如何在这里工作 )。
In your case, you could try this: 在你的情况下,你可以试试这个:
Ext.query("#container input:checked")
Of course, this will only obtain DOM values rather than Ext components. 当然,这只会获得DOM值而不是Ext组件。
如果您使用的是CheckboxGroup对象,则可以使用getValues()方法,该方法将返回一个Checkboxes数组,您可以使用它来查看值...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.