Results 1 to 2 of 2

Thread: Using the inclusion validator with a list from an external store

  1. #1
    Sencha User
    Join Date
    May 2016
    Posts
    4
    Vote Rating
    0
      0  

    Default Using the inclusion validator with a list from an external store

    Hello,

    I've been looking into using the model validator for type: inclusion.

    I see that I can add a list like this:
    Code:
    {type: 'inclusion', list: ['None', 'Facility', 'Program', 'Ship']}
    and everything is well and good.

    But what if I want to add a list from an external store? I'm unable to look the store up through StoreManager where my store looks like:

    Code:
    Ext.define('Ext.store.enums.SystemTypeEnum', {
        extend: 'Ext.data.Store',
        alias: 'store.SystemTypeEnum',
        storeId: 'SystemTypeEnum',
        fields: ['id', 'name'],
        data: [
            { id: 0, name: 'None' },
            { id: 1, name: 'Facility' },
            { id: 2, name: 'Program' },
            { id: 3, name: 'Ship' }
        ], 
        filters: [
            function (item) {
                return item.id > 0;
            }
        ]
    });
    I know this won't give me the correct result I need, but currently it won't get me anything:
    Code:
    {type: 'inclusion', list: Ext.StoreMgr.lookup('SystemTypeEnum') ? Ext.StoreMgr.lookup('SystemTypeEnum') : ['test']}
    I also cannot create a function in the list config either.

    I've tried doing something along the lines of:
    Code:
    {type: 'inclusion', list: function() {
    		var test = Ext.StoreMgr.lookup('SystemTypeEnum');
    		var range = [];
    		if (test) {
    			range = test.getRange();
    		}
    		return range;
    }}
    and the function never gets called.

    Is there some obvious way that I'm missing that could solve this problem?

    Thanks in advance for any help!

  2. #2
    Sencha User
    Join Date
    May 2016
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Update:

    I've created a custom validator that takes the storeId as a config, and then down in the validation I find that store and then get the list and validate that way.

    I don't know if this is the best way to attack the problem, but for now it's working.

    I'd love to hear if anyone has any cleaner ideas that can have me using the out of the box validator.

Similar Threads

  1. Inclusion Validator with a list from an external store
    By tcochenour in forum Ext 6: Q&A
    Replies: 1
    Last Post: 16 May 2018, 7:00 AM
  2. A small problem to feed my list with store in external class
    By Ocelyn in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 7 May 2012, 5:07 AM
  3. Replies: 1
    Last Post: 6 Dec 2011, 6:58 AM
  4. Example of an external store call for Ext.List
    By lbuijsma in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 4 Oct 2010, 3:42 PM

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
  •