PDA

View Full Version : Store don't sync updated records



American horizon
7 Jun 2016, 2:55 AM
this is my code that i launch once the save button of a form is pressed:



var store = Ext.create('CS.store.Titolari', {
buffered:false,
autoLoad:false});
store.add( btn.up("form").getValues());
store.sync();

The form have an hidden field that represents id, so considering that it is filled, the store know that it's an updated record(not a new one). But when i call sync() method i see that no network call is performed.

This is my store




Ext.define
(
"CS.store.Titolari",
{
extend:"Ext.data.Store",
model:"CS.model.Titolare",
alias: 'widget.titolaristore',
buffered: true,
pageSize: 1000,
leadingBufferZone:0,
trailingBufferZone:0,

proxy:
{
type:"ajax",
headers : {'Content-type' : 'application/json','accept': 'application/json'},
api: {
create : 'titolari',
read : 'titolari',
update : 'titolari',
destroy : 'titolari'
},
reader:
{
type:"json",
totalProperty: 'totalCount',
root:"\list",
messageProperty: 'message'
},
writer:{
type:"json",
writeAllFields: false,
messageProperty: 'message',
idProperty: "id"

}
}, //chiude proxy

autoLoad: true,
autoSync:false,

actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
}
}
);

Gary Schlosberg
7 Jun 2016, 12:28 PM
Can you please post your form code?

American horizon
7 Jun 2016, 11:19 PM
Ext.define('CS.view.TitolareForm', {
extend: "Ext.form.Panel",
alias: 'widget.titolareform',
bodyPadding: 5,
width: 750,
mode: "",
headers: { 'Content-Type': 'application/json;charset=utf-8' },
url: "titolari",
title: "Anagrafica",
layout: 'vbox',
height: 400,
width: 800,
fieldDefaults: {
labelAlign: 'top',
labelWidth: 100,
},
defaults: {
margin: '0 0 0 0',
disabledCls: 'form-field-disabled'
},
defaultType: 'textfield',

items: [
{
xtype:"textfield",
name:"id",
hidden: true
},

//****PRIMA RIGA
{
xtype: "container",

layout: "hbox",
width: 750,
defaultType: 'textfield',
defaults: { margin: '10 10 10 10',
disabledCls: 'form-field-disabled'},
flex:1,
items: [
{
fieldLabel: 'Nome',
name: 'nome',
allowBlank: true,
flex:1,
},
{
fieldLabel: 'Cognome',
name: 'cognome',
flex:1,
allowBlank: true,
},
{
fieldLabel: 'Ragione Sociale',
name: 'ragioneSociale',
flex:1,
allowBlank: true,
},
{
fieldLabel: 'Sesso',
name: 'sesso',
allowBlank: true,
store: 'Sesso',
displayField: "cod_sesso",
valueField: "cod_sesso",
flex: 0.2
}
]
},


//****SECONDA RIGA
{
xtype: "container",
layout: "hbox",
width: 750,
defaultType: 'textfield',
defaults: {
margin: '10 10 10 10',
disabledCls: 'form-field-disabled'
},
flex:1,
items: [
{
xtype: "datefield",
alias: "dataNascita",
fieldLabel: 'Data di Nascita',
name: 'dataNascita',
allowBlank: true,
disabledCls: 'form-field-disabled',
width: 100,
dateFormat: 'dd-mm-yyyy',
},
{
fieldLabel: '#',
labelSeparator : "",
name: '',
alias: "txtNazioneNascita",
allowBlank: true,
width:35,
isFormField: false,
disabledCls: 'form-field-disabled',
margin: "10 0 10 10",
},
{
xtype: 'combobox',
queryMode: "local",
alias: 'cmbNazioneNascita',
fieldLabel: 'Nazione di Nascita',
name: 'idNazioneNascita',
margin: "10 10 10 0",
allowBlank: true,
displayField: "label",
},
{
fieldLabel: '#',
labelSeparator : "",
name: '',
alias: "txtProvinciaNascita",
allowBlank: true,
isFormField: false,
width:35,
margin: "10 0 10 10",
enableKeyEvents:true,
},
{
xtype: 'combobox',
alias: 'cmbProvinciaNascita',
queryMode: "local",
margin: "10 10 10 0",
fieldLabel: 'Provincia di Nascita',
name: 'idProvinciaNascita',
allowBlank: true,
displayField: "label",
valueField: "id",
},

{
fieldLabel: '#',
labelSeparator : "",
name: '',
alias: "txtComuneNascita",
allowBlank: true,
width:35,
isFormField: false,
margin: "10 0 10 10",

},
{
xtype: 'combobox',
alias: "cmbComuneNascita",
queryMode: "local",
margin: "10 10 10 0",
fieldLabel: 'Comune di Nascita',
name: 'idComuneNascita',
displayField: "label",
valueField: "id",
allowBlank: true,
flex: 1,
},
]
},

//****TERZA RIGA
{
xtype: "container",
layout: "hbox",
width: 750,
defaultType: 'textfield',
defaults: {
margin: '10 10 10 10',
disabledCls: 'form-field-disabled'
},
flex:1,
items: [
{
fieldLabel: 'Localita\' di Nascita',
name: 'localitaNascita',
alias: 'localitaNascita',
allowBlank: true,
readOnly: true,
cls: "form-field-disabled"
},
{
fieldLabel: 'Codice Fiscale',
name: 'codiceFiscale',
allowBlank: true,
flex: 1,
},
{
fieldLabel: 'Partita IVA',
name: 'partitaIVA',
allowBlank: true,
flex: 1,
}
]
},

//**** QUARTA RIGA
{
xtype: "container",
layout: "hbox",
width: 750,
defaultType: 'textfield',
defaults: {
margin: '10 10 10 10',
disabledCls: 'form-field-disabled'
},
flex:1,
items: [
{
xtype: 'combobox',
alias: "cmbNazionalita",
queryMode: 'local',
fieldLabel: 'Nazionalita\'',
name: 'idNazionalita',
allowBlank: true,
flex: 1,
displayField: "label"
},
{
fieldLabel: '#',
alias: "txtAcCompetenza",
labelSeparator : "",
name: '',
isFormField: false,
allowBlank: true,
margin: "10 0 10 10",
width:35,
},
{
xtype: 'combobox',
alias: 'cmbAcCompetenza',
fieldLabel: 'AC Competenza',
queryMode: "local",
name: 'acCompetenza',
margin: "10 10 10 0",
allowBlank: true,
displayField: "label",
valueField: "id",
flex: 1,
{
xtype: 'checkbox',
fieldLabel: 'Licenziabile',
name: 'flagLicenziabile',
allowBlank: true,
inputValue: 1,
uncheckedValue: 0,
},
{
xtype: 'checkbox',
fieldLabel: 'Riservato',
name: 'flagRiservato',
allowBlank: true,
inputValue: 1,
uncheckedValue: 0,
}
]
},

//****QUINTA RIGA

{
xtype: "container",
layout: "hbox",
width: 750,
defaultType: 'textfield',
defaults: {
margin: '10 10 10 10',
disabledCls: 'form-field-disabled'
},
flex:1,
items: [
{
fieldLabel: 'Utente Creazione',
name: 'idUtenteCreazione',
allowBlank: true,
flex: 1,
},
{
xtype: "datefield",
fieldLabel: 'Data Creazione',
name: 'dataCreazione',
allowBlank: true,
width: 100,
},
{
fieldLabel: 'Utente Modifica',
name: 'idUtenteModifica',
allowBlank: true,
flex: 1,
},
{
xtype: "datefield",
fieldLabel: 'Data Modifica',
name: 'dataModifica',
allowBlank: true,
width: 100,
}
]
}
],



buttons: [

{
text: '<span style="color:white">Invia Modifiche</span>',
alias: 'btnModifica',
formBind: true, //only enabled once the form is valid
style: "background-image: url('./images/extras/orange.png') !important"

}

],




});