Check empty store

  1. #1

    Check empty store

    I am using the below function to check for empty store - says records is null or not an object?




    var hospitalsLoad = function(value, metadata, records, rowIndex, colIndex, store) {


    if(!Ext.isEmpty(records) && records.length > 0){


    Hospitals.setDisabled(false);


    Hospitals.setValue(Hospitals.store.getAt(0).get('i d'));


    }


    else{


    Hospitals.setDisabled(true);}


    }
  2. #2

    RE: Check empty store

    the below seems to work - but is it valid/best practice?




    var hospitalsLoad = function(value, metadata, records, store) {


    if(this.getCount() > 0){


    Hospitals.setDisabled(false);


    Hospitals.setValue(this.getAt(0).get('id'));


    }


    else{


    Hospitals.setDisabled(true);}


    }
  3. #3

    RE: Check empty store

    Hi,

    How hospitalsLoad is using?
    For check the Store just call store's getCount function (it should be greater then 0)
  4. #4

    RE: Check empty store

    getCount seems to be working - via of the store itself




    <Listeners>


    <Load Fn="hospitalsLoad" />


    </Listeners>
  5. #5

    RE: Check empty store

    Hi,

    Load event of the Store has another signature
    load : ( Store this, Ext.data.Record[] records, Object options )

Similar Threads

  1. Replies: 1
    Last Post: Apr 01, 2012, 3:42 PM
  2. How to check whether Store is empty or not?
    By gaozheng1028 in forum 1.x Help
    Replies: 1
    Last Post: Nov 24, 2011, 12:27 PM
  3. Replies: 8
    Last Post: Dec 16, 2010, 11:10 AM
  4. [CLOSED] Check if Store is empty
    By tjshin in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 10, 2010, 5:37 PM
  5. Replies: 0
    Last Post: Jun 26, 2009, 11:32 AM

Posting Permissions