PDA

View Full Version : How to save Client-side Form data to Store



Arsenalka
22 May 2014, 8:27 AM
Hello!

I have got a Demoproject from a company. I need to do everything in client-side. I get from them a .js file what contains the data. It's okey, I can read it to a JsonStore. My problem is the next:

I need to create a form for a transaction, I have accounts and I need to manipulate them, so I need to reduce the available balance and show this transaction with the others.

Can somebody give me a code with a store with one field and a form with one textfield or any other and if you press a button, then this textfield value added to the store and the file too.

I hope somebody can help me.

Arsenalka
22 May 2014, 9:15 AM
Ext.BLANK_IMAGE_URL = '../../www/lib/extjs/resources/images/default/s.gif';
Ext.ns('Application');
Ext.onReady(function () {


var nevstore = new Ext.data.ArrayStore({
fields: [{
name: 'name'
}],
data: [
['elsoember'],['masodiknev'],['harmadasd']]


});




var nevgrid = new Ext.grid.GridPanel({
applyTo: 'nevgrid',
title : 'Grid',
id: 'usersgrid',
store : nevstore,
columns: [
{header: 'Nev', dataIndex: 'name'}],
width: 200,
height: 200
});


var nevform = new Ext.form.FormPanel({
applyTo: 'nevform',
width: 200,
height: 200,
title: 'Form',
items: [{
xtype: 'textfield',
fieldLabel: 'Nev',
name: 'name',
id: 'name'
}],
buttons: [{
text: 'Mentes',
handler: function(b,e){
var nev = Ext.getCmp('name').getValue();
var userRecord = null;
var store = Ext.getCmp('usersgrid').getStore();
store.add(new store.recordType({
name: nev
}));
}
}]
})




});


I found this, it is working, but it is using ArrayStore, I need it to work with JsonStore and I moving data to separately file and loading it, but it is not saved to it.