Results 1 to 8 of 8

Thread: != Selector (not equals) doesn't work

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Vote Rating
    1
      0  

    Default != Selector (not equals) doesn't work


    Ext version tested:

    • Ext 4.1.1.rc1

    Browser versions tested against:
    • FF16

    Description:
    • Query a form panel for fields that do not match an attribute

    Steps to reproduce the problem:
    • var results = form.query("field[inputType!='hidden']");

    The result that was expected:
    • an array with all the fields that are not inputType "hidden"

    The result that occurs instead:
    • returns an array of only the fields with inputType "hidden"
    • in other words the same as :
    • var results = form.query("field[inputType='hidden']");

    Test Case:

    http://jsfiddle.net/dbVdJ/

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    This isn't a bug, the != operator isn't defined, nor it is listed in the docs. Similar to css selectors, it's intended that you use the :not selector:

    Code:
    cq.query(':not([hidden])');
    Evan Trimboli
    Twitter - @evantrimboli

  3. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Vote Rating
    1
      0  

    Default

    Thanks for your reply.


    Unfortunately it is listed in the documentation:

    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.dom.Query

    E[foo!=bar] attribute "foo" does not equal "bar"

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    dom.Query and ComponentQuery are not the same thing.
    Evan Trimboli
    Twitter - @evantrimboli

  5. #5
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Vote Rating
    1
      0  

    Default

    My bad...

    But your example returns all the fields

    http://jsfiddle.net/dbVdJ/2/



    Code:
    form.query(":not([hidden])");
    or
    Code:
    form.query("field:not([hidden])");

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    Yes, I just copied that from the code somewhere, you'd still need to check the inputType.
    Evan Trimboli
    Twitter - @evantrimboli

  7. #7
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Vote Rating
    1
      0  

    Default

    excellent thank you

    Here is the solution:


    Code:
    form.query("field:not([inputType=hidden])");

  8. #8
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Vote Rating
    1
      0  

    Default

    just for others:

    multiple chains (i.e. not hidden and not label = "hello2"):

    form.query("field:not([inputType=hidden]):not([fieldLabel='hello2'])");

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •