0

i use a store with a model. The jason has a value i want to use in an alert. The json is like this

{"slapen":[{"naam":"test","leeftijd":"43"},{"naam":"test2","leeftijd":"27"}]}

i want to display an alert for the first result. So when the store is loaded i want an alert like this

alert('De eerste winnaar is {here_comes_leeftijd} jaar');

so the number is what i want to show. Is this possible?

winnaars = new Ext.data.Store({
    model: 'stepDetails',
    pageSize: 20,
    loadMask: false,
    sortOnLoad: true,

    proxy: {
        type: 'ajax',
        url: detailURL,
        startParam: '',
        limitParam: '',
        pageParam: '',
        reader: {
            type: 'json',
            root: 'slaevents'
        }
    },
    autoLoad: false
});
0

1 Answer 1

1

You can listen to the store's load event (either externally or by using the listeners config) and inspect the returned records there and act upon them.

winnaars = new Ext.data.Store({
    model: 'stepDetails',
    pageSize: 20,
    loadMask: false,
    sortOnLoad: true,

    proxy: {
        type: 'ajax',
        url: detailURL,
        startParam: '',
        limitParam: '',
        pageParam: '',
        reader: {
            type: 'json',
            root: 'slaevents'
        }
    },
    autoLoad: false


    listeners: {
        load: function( aStore, aRecords, aSuccess, aeOpt) {
            // Do something here.
            console.log(aRecords);
        }
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

thanks! This gives all the records in my console. How can i get the "leeftijd" from the first result?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.