views:

32

answers:

1

Hi,

I have list of check box as:

test1 test2 test3

is it possible to get all the checkbox having name "abcd_xyz_2_*" thru extjs. so that i can make them checked or unchecked

THanks All

+1  A: 

If you know the exact names of the fields you want to check then you can do so with a single call to the containing form's setValues method.

Assuming the checkboxes are in an Ext.form.FormPanel instance named 'form':

form.getForm().setValues({
    test1: true,
    test2: true,
    test3: true
});

If you still need to set by ID prefix then you can do something like:

form.items.each(function( item ) {
    if ( item.getId().indexOf('abcd_xyz_2_') === 0 ) {
        item.setValue(true);
    }
});

To manipulate generic checkbox elements in the page which are not contained in any ExtJS panels you can use Ext.query:

Ext.each(Ext.query('input[id^=abcd_xyz_2_]'), function( item ) {
    item.checked = true;
});
owlness
Thanks for your quick replyBut its not a Ext.form.FormPanel instance named 'form'. Its just a html page
Check the updated answer for a way to query and manipulate generic elements.
owlness
THX owlness for your help