kostepanych
kostepanych

Reputation: 2619

ExtJs select component by itemId starting with a string

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?

Upvotes: 0

Views: 665

Answers (1)

Fabio Barros
Fabio Barros

Reputation: 1439

If you are using extjs checkboxes, you could do it like this:

//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);

if is pure html just use:

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

Upvotes: 1

Related Questions