1

I tried to find the answer a lot but no way. I have an Ext.data.ArrayStore store and want to get its data as string. I tried store.getRange(), store.getAt() but I couldn't figure out what these functions return. Is there any way to get ArrayStore data as string?

I am newbie to extjs, so if you have any example on this, I'd appreciate.

2
  • what do you mean "as a string" can you provide an example of the data and the output you want? Commented Jun 24, 2011 at 19:52
  • when i put data into store, lets say i use [['name1','value1'],['mane2','value2']]. then i want to retrieve name1&value1 and name2&value2. even if it is in the format of [['name1','value1'],['mane2','value2']], that's still ok. Commented Jun 24, 2011 at 20:26

1 Answer 1

2

It really depends what you want to do with the data. For most UI widgets and that sort of thing, you'll want to just use the store directly. If you want to get a piece of data from the store for tweaking manually, that's a whole nother story.

store.getRange() will indeed return all of the records from the store, but they are returned as an Array of Record objects. Records contain an attribute called data which is an object containing any properties you defined in the record's config.

Example:

Ext.each(store.getRange(), function (item, idx, a) {
  for (var i in item.data) {
    console.log(item.data[i])
  }
})

That should show you every item in every Record in store

EDIT: Changed my answer to not be totally wrong.

Sign up to request clarification or add additional context in comments.

3 Comments

it still gives me an object. so how do i take its data when i get an object? what i want is actually, i want to load data from server (can say i achieved) and want to store/update when changed.
@fitne corrected my answer. The fields in each record are those you defined in the store's config - 'fields' of the ArrayStore.
missing ); at the end but perfect. that's what i want. :)

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.