PDA

View Full Version : [CLOSED] Get JSON representation of store



livehealthierGF
Jun 25, 2013, 3:48 PM
Trying to get JSON string representation of data in the store. This code works well:


Ext.encode(Ext.pluck(Ext.getStore('strUserData').d ata.items, 'data'))

Got - [{ "id":4224,"value":1,"date":"2013-06-11T00:00:00","value1":0}...]
In my store I have mappings:


<ext:Model ID="Model2" runat="server" IDProperty="id">
<Fields>
<ext:ModelField Name="id" ServerMapping="Id" Type="Int" Mapping="Id" />
<ext:ModelField Name="value" ServerMapping="Value" Mapping="Value"/>
<ext:ModelField Name="date" ServerMapping="Date" Type="Date" Mapping="Date"/>
<ext:ModelField Name="value1" ServerMapping="Value1" Mapping="Value1"/>
</Fields>
</ext:Model>

Is it any way to get 'mapped' data? Something like ( [{ "Id":4224,"Value":1,"Date":"2013-06-11T00:00:00","Value1":0}...]?

Daniil
Jun 25, 2013, 4:03 PM
Hi @livehealthierGF,

Please use

store.getRecordsValues();

It saves mapping by defaults.

By the way, using ServerMapping and Mapping at the same time looks a kind of weird. What kind of data do you bind to that model?

livehealthierGF
Jun 25, 2013, 4:30 PM
Hi @livehealthierGF,

Please use

store.getRecordsValues();

It saves mapping by defaults.

By the way, using ServerMapping and Mapping at the same time looks a kind of weird. What kind of data do you bind to that model?

I'm loading store first time with ServerMappings (codebehind)and then just sync it with 'lightweight' static directmethod where I get back json if data changed and empty string if not, so:


if (data != '')
Ext.getStore('strUserData').loadRawData(data);

Daniil
Jun 26, 2013, 3:35 AM
Ok, thank you for clarifying.

Does the getRecordsValues method help you?