View Full Version : Basic manipulating stores and data

5 May 2014, 1:34 PM

New to ExtJS and trying to work out how best to use stores and data. I'm trying to learn by project so giving an anagram solver a go. E.g. Enter a word and get a list of words held in store which are anagrams of the word you provide.

The list of words are in JSON format which is held in a store linked to a model.

There are only two fields in the store and model. Word and Definition.

I am going to take the word data, sort it alphabetically and create a list of arrays from 1-x values that have the same alphabetical key.

alphabetised key : array of words
'opst' : ['post', 'pots', 'spot', 'stop' 'tops']

I have used the three panel example from the layout template: Header/ Left/ Content/ Right/ Footer

Left will hold
a text input for box for entering your word a button for submitting the form
a button that will create the alphabetised word : array object

Center will hold
number of anagrams
the list of words

Right will hold the initial JSON data.

Header/Footer: nothing yet

What I can't seem to wrap my head around is how to store the alphabetised data.

Do I create
a separate store/model for it?
a separate store but use the existing model and add the fields alphabetisedWord and arrayOfWords?

My second question is related to ExtJSs MVC concept. Where do I put the business logic for creating the alphabetised array? I was thinking of putting it in the controller on the onCreateAlphabetisedArrayClick event, but isnt it proper to put it on the model?

Hope you can help,

5 May 2014, 5:57 PM
I would perform this as the server level. There are numerous SQL examples for anagram queries. Then simply return the result