ExtJs select component by itemId starting with a string

时间:2019-05-31 11:23:52

标签: extjs extjs4.1

Using Ext Js 4.1.

I have multiple checkboxes in panel with ids and itemIds: 'chA104', 'chA204', 'chB111' etc. And I want to get all checkboxes that starts with id (or itemId) = 'chA' to make them disabled.

How to do that? Tryed to use this:

this.query('*[id^=chA]');

But get an array with multiple elements: table, td, input etc. When doing this:

Ext.query('input[id^=chA]')[0]

I get an html input element. But when trying to do:

Ext.query('input[id^=chA]')[0].disable();
Ext.query('input[id^=chA]')[0].setDisabled(true);

I get an error.

So how to get all checkboxes, starting with a string id (or itemId) and make them enabled/disabled?

1 个答案:

答案 0 :(得分:1)

如果您正在使用extjs复选框,则可以这样做:

//enable/disable
Ext.ComponentQuery.query('checkboxfield{id.search("chA")!=-1}')[0].disable(); 
//check/uncheck                           
Ext.ComponentQuery.query('checkboxfield{id.search("chA")!=-1}')[0].setValue(true);

如果是纯HTML,请使用:

//enable/disable
Ext.query('input[id^=chA]')[0].disabled = true;
//check/Uncheck
Ext.query('input[id^=chA]')[0].checked = true;