简体   繁体   中英

Using XTemplate with SimpleStore in Ext

I am currently adding some functionality to some old code. There used to be a template which took a flat array of items and spat out some HTML, now the data is coming from a simple store which reads some JSON..

var allwords = [
    ['abacteriano', 'abacteriano'],
    ['abacterial', 'abacteriano'],
    ['abciximab', 'abciximab'], ...
]

So my simplestore goes like this:

    termStore = new Ext.data.SimpleStore({
        fields: ['term', 'lookup'],
        data: allwords
    });

This definitly works fine as I use the termStore in a combobox. However I am having difficulty getting it to play with an XTemplate.

It seems the syntax in extjs doesn't play well with SO, so this bit wont be in a code block...

So I guess I'll describe it :p

Essentially its a simple template which tries to get values out of the passed collection by doing {term}

I then try and apply it by doing:

tpl.overwrite(Ext.get("contentbox"), termStore);

This gives me a JS error of "invalid object initializer"

XTemplate works with simple objects or arrays, not afaik, simplestores. Try binding it to your allwords array instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM