Results 1 to 4 of 4

Thread: Filter question

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default Unanswered: Filter question

    Hi,

    I am beginner to Sencha. I am writing one simple program where I have to filter some store data.
    If I do this in test project, it works. But in actual project the store.filter() always return empty list. There is absolutely no difference between two projects as far as code is concerned. I observed one thing though, in my test project, store.getData() returns following info.

    Class
    • _autoFilter: true
    • _autoSort: true
    • _filterRoot: "data"
    • _filters: Class
      • _autoFilter: true
      • _autoSort: true
      • all: Array[1]
        • 0: Class
          • _filterFn: function (item) {
          • _id: "optionid-1"
          • _property: "optionid"
          • _root: "data"
          • _value: 1


    and in actual project, the same variable is displayed as:

    Class

    • _autoFilter: true
    • _autoSort: true
    • _filterRoot: "data"
    • _filters: Class
      • _autoFilter: true
      • _autoSort: true
      • all: Array[1]
        • 0: Class
          • _filterFn: function (item) {
          • _id: Class
          • _property: Class
          • _root: "data"

    Portion marked in red is the only difference i can think of. Would this cause issue? Is it due to referring different jar files?

    Thanks in advance






  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    code?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default Code

    hey!! thanks for reply, please go though the code below:

    Test project code:[working]

    Ext.define('Test.view.TeenPage',{
    extend:'Ext.form.Panel',
    xtype:'teenpage',
    id:'teenpage',
    config:{
    title: 'Teen!',
    layout:'card',
    listeners: {
    painted:function() {
    console.log("Inside painted");
    store = Ext.getStore('TeenStore');

    store.clearFilter();
    var filter = new Ext.util.Filter({
    property: 'optionid', value: 1
    });

    store.filter(filter);
    console.log(store.getData());
    }
    },
    },
    });

    Actual Page code:

    Ext.define('Actual.view.login.TeenPage',{
    extend:'Ext.form.Panel',
    xtype:'teenpage',
    id:'teenpage',
    config:{
    title: 'Teen!',
    layout:'fit',

    listeners: {
    painted:function() {
    console.log("Inside teen page painted");
    store = Ext.getStore('TeenStore');

    store.clearFilter();
    var filter = new Ext.util.Filter({
    property: 'optionid', value: 1
    });
    store.filter(filter);
    console.log(store.getData());
    }
    },
    }
    });

    Thanks,

  4. #4
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default adding list code

    Additions marked inline
    TEST:
    Ext.define('Test.view.TeenPage',{
    extend:'Ext.form.Panel',
    xtype:'teenpage',
    id:'teenpage',
    config:{
    title: 'Fun for Teen!',
    layout:'card',
    listeners: {
    painted:function() {
    store = Ext.getStore('TeenStore');
    store.clearFilter();
    var filter = new Ext.util.Filter({
    property: 'optionid', value: 1
    });
    store.filter(filter);
    }},
    items:[
    {
    xtype:'list',
    store:'TeenStore',
    itemTpl:'<h1>{optionid}.{question}</h1> \
    <h2> \
    <input type="radio" name="Q1Answer" value= {option1}/> {option1}<br/> \
    <input type="radio" name="Q1Answer" value= {option2}/> {option2}<br/> \
    <input type="radio" name="Q1Answer" value= {option2}/> {option3}<br/> \
    </h2>'
    },
    ]},
    });

    Actual:
    Ext.define('SLAL.view.login.TeenPage',{
    extend:'Ext.form.Panel',
    xtype:'teenpage',
    id:'teenpage',
    config:{
    title: 'Fun for Teen!',
    layout:'card',

    listeners: {
    painted:function() {
    store = Ext.getStore('TeenStore');
    store.clearFilter();
    var filter = new Ext.util.Filter({
    property: 'optionid', value: 1
    });
    store.filter(filter);
    }},
    items:[
    {
    xtype:'list',
    store:'TeenStore',
    itemTpl:'<h1>{optionid}.{question}</h1> \
    <h2> \
    <input type="radio" name="Q1Answer" value= {option1}/> {option1}<br/> \
    <input type="radio" name="Q1Answer" value= {option2}/> {option2}<br/> \
    <input type="radio" name="Q1Answer" value= {option2}/> {option3}<br/> \
    </h2>'
    },
    ]}
    });

Posting Permissions

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