[CLOSED] jQuery and Ext.Net

  1. #1

    [CLOSED] jQuery and Ext.Net

    So, I've built a control that uses a bunch of fields that are dynamically created.

    The fields consist of TextFields and SelectBoxes and ComboBoxes.

    However, I'm using jquery to "clear" the fields. I have figured out how to clear the text fields, but how do I:

    1. Select a different index on selectboxes/comboboxes using jQuery.
    2. And, clear the selectboxes/comboboxes so it shows the default Empty Text that has been defined using jquery?

    I must be missing something on how to access ExtJS controls via jquery.

    Any help?

    Thanks.
    Last edited by Daniil; Oct 14, 2011 at 3:49 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please clarify why don't you want to access components using standard ExtJS mechanism?
  3. #3
    I should point out that there is a .clear() function on all Fields.

    Example

    TextField1.clear(); // client-side JavaScript
    
    TextField1.Clear(); // server-side
    1. Select a different index on selectboxes/comboboxes using jQuery.
    You can select the index using jQuery by using ExtJS.

    http://dev.sencha.com/deploy/ext-3.3...&member=select

    or

    http://dev.sencha.com/deploy/ext-3.3...=selectByValue

    2. And, clear the selectboxes/comboboxes so it shows the default Empty Text that has been defined using jquery?
    Set the .EmptyText property of the Field, then call .clear().

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Right.

    However, the controls are created dynamically during the Page_Load based on database data.

    I don't know the names of the fields specifically when on the client side. In jquery, I could typically just call something like:

    $('myfielddiv div input[type=text]') using ExtJS to grab all the input fields and manipulate them.

    How is this possible using ExtJS and jQuery? Or an alternative using ExtJS?
  5. #5
    Well, you can use this code:

    Example 1
    Ext.ComponentMgr.all.each(function (c) {
        if (c instanceof Ext.form.Field && c.clear) {
            c.clear(); // may it would be more appropriate to use .reset()
        }
    });
    Please note that you can loop items collection of any container:

    Example 2
    FormPanel1.cascade(function (c) {
        if (c instanceof Ext.form.Field && c.clear) {
            c.clear(); // may it would be more appropriate to use .reset()
        }
    });
    See also:
    http://dev.sencha.com/deploy/ext-3.4...t.ComponentMgr
    http://dev.sencha.com/deploy/ext-3.4...d&member=reset
    http://dev.sencha.com/deploy/ext-3.4...r&member=items
    http://dev.sencha.com/deploy/ext-3.4...member=cascade
    http://dev.sencha.com/deploy/ext-3.4...on&member=each
  6. #6
    $('myfielddiv div input[type=text]') using ExtJS to grab all the input fields and manipulate them.
    What you're getting here is a list of DOM objects. I think the exact same query can be run in ExtJS using Ext.get(...).

    Example

    Ext.get('myfielddiv div input[type=text]')
    The catch here is that you're then working with basic DOM objects and not Ext Component objects. If you have a collection of Component objects then you'll get access to the full api of those objects/classes. For that you'll need the ComponentManager as noted above by @daniil.

    Hope this helps.
    Geoffrey McGill
    Founder
  7. #7
    This worked! Thanks.

Similar Threads

  1. [CLOSED] ext and jquery
    By sisa in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 05, 2011, 2:18 PM
  2. [CLOSED] Coolite with JQuery
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 08, 2011, 11:20 AM
  3. Jquery & Ext.NET
    By threewonders in forum 1.x Help
    Replies: 3
    Last Post: Jun 16, 2011, 7:01 PM
  4. [CLOSED] validation with JQuery
    By rnfigueira in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 23, 2011, 3:06 PM
  5. jQuery and ASP.NET
    By jchau in forum Open Discussions
    Replies: 2
    Last Post: Oct 11, 2008, 4:02 PM

Posting Permissions