PDA

View Full Version : Extjs 4.1.1 does not save nothing



icebergdelphi
15 Jul 2012, 6:02 PM
Hi all. i´m testing extjs 4.1.1, but i found 1 bug, i just work with MVC architecture, i have my PHP file for Create new records(File create.php), my Model and my store, but when i make insert or create a new record, and then i click my save button, Extjs 4.1.1 does not save nothing. But when i'm testing with extjs 4.0.7 all works fine.
So what is really happens with the new version?
i miss something?
Note: Everything works perfectly fine if I work with ExtJS version 4.0.7, with version 4.1.1 in the firebug shows me no trace of anything.
Thanks.

here my code:
index.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="eng">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PREP Candidatura Bulmaro Castillejos Calvo</title>
<link rel="stylesheet" type="text/css" href="/ext-4.1.1/resources/css/ext-all.css" />
<!-- Iconos del Sistema -->
<link rel="stylesheet" type="text/css" href="/Prep/resources/css/Prep.css" />

<!-- En las lineas siguientes, para cuando se esta desarrollando se pone:ext-all-dev.js, en produccion ext-all.js-->
<!-- No olviden cambiar el Nombre de la Carpeta Extjs4, tal como la tienen en su equipo en mi caso: Yo la tengo nombrada como ext-4.1.0 -->


<script type="text/javascript" src="/ext-4.1.1/ext-all.js"></script>

<!-- Archivos Js de la Aplicacion y recursos-->
<script type="text/javascript" src="/Prep/App/App.js"></script>
<!-- Traductor del Sistema-->
<script type="text/javascript" src="/Prep/resources/ux/ext-lang-es.js"></script>



</head>



my update an save controller action:


ActualizarVotos: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();

if (values.IdPrepdetalle > 0){ //Si Hay algun Valor, entra en Modo de Actualizacion
record.set(values);
} else{ //De Lo contrario, si la accion fue para agregar, se inserta un registro
record = Ext.create('Prep.model.Voto.Voto');
record.set(values);
record.setId(0);
this.getVotoVotoStore().add(record);
}
win.close();

},


my model:


Ext.define('Prep.model.Voto.Voto', {
extend: 'Ext.data.Model',
fields: [
{ name: 'IdPrepdetalle', type: 'int'},
{ name: 'IdLocalidad', type: 'int'},
{ name: 'Localidad', type: 'string'},
{ name: 'IdMunicipios', type: 'int'},
{ name: 'Municipio', type: 'string'},
{ name: 'PanVoto', type: 'int'},
{ name: 'PriPochVoto', type: 'int'},
{ name: 'PrdPtCoalVoto', type: 'int'},
{ name: 'AlianzaVoto', type: 'int'},
{ name: 'VotoNulo', type: 'int'},
{ name: 'Sobrantes', type: 'int'},
{ name: 'IdSeccion', type: 'int'},
{ name: 'Seccion', type: 'string'},
{ name: 'IdTipoCasilla', type: 'int'},
{ name: 'Casilla', type: 'string'}
]
});

my store:


Ext.define('Prep.store.Voto.Voto', {
extend: 'Ext.data.Store',
model: 'Prep.model.Voto.Voto',//Llamamos el Modelo Antes Creado
id:'StoreVoto',
autoSync: true,//Sincronizacion con el Servidor
autoSave: true, //<--- hace las peticiones al servidor automáticamente
proxy: {
type: 'ajax',
api: { //Declaramos la API y Comienzan en estas lineas las operaciones CRUD
read : "/Prep/Php/view/Prep/PrepRead.php",
create : "/Prep/Php/view/Prep/PrepCreate.php",
update : "/Prep/Php/view/Prep/PrepUpdate.php",
destroy : "/Prep/Php/view/Prep/PrepDestroy.php"

},
actionMethods:{ //Esta Linea es necesaria para que funcione el SearchField
read:'POST'
},
reader: {
type: 'json',
idProperty: 'IdPrepdetalle',
successProperty : function(response,options)
{

},
root:'data' //Json_encode root:Datos del Servidor desde desde TCD.php

},
writer:{
encode: true,
writeAllFields: true,//decide si se manda al servidor solamente los campos modificados o todo
type: 'json',
root: 'data'

},
//Mensajes Extras si deseas agregarlos
afterRequest: function (request, success)
{

if (request.action == 'read')
{
//Ext.Msg.alert('Title','Read');
}

else
if (request.action == 'update')
{

/*var jsonMsg = Ext.JSON.decode(request.operation.response.responseText);
var vMsg=jsonMsg.msg; //msg :viene del Archivo PHP
Ext.Msg.alert('Actualizacion',vMsg);*/

}
},
listeners: {
exception: function(proxy, response, operation){

Ext.MessageBox.show({
title: 'ERROR',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
},


}

}
});

mkysoft
15 Jul 2012, 11:24 PM
when you manuel add data in store, it's dirty status is always false. You must set records' dirty parameters to true.

icebergdelphi
16 Jul 2012, 6:18 AM
Thanks friend, but this is not the solution, i remind you, when i'm using extjs 4.0.7 everything works fine, i'm just testing extjs 4.1.1, because i want to upgrade my framework from 4.0.7 to 4.1.1, i just add dirty:true to my model but nothing happens with 4.1.1,i think the model does not send the post action to my php file ;
i think i'm gonna downgrade to 4.0.7, thanks.:(

scottmartin
16 Jul 2012, 8:01 AM
Do you see anything in your header .. is nothing sent to server an all, or just not updated?
You are hard setting your id on add?

This is most likely setting record.phantom to false and then it cannot 'insert' so it us trying to update there is not matching record.

Try setting record.phantom = true, or better yet .. simply do not set your record id on the client and let your server handle this as it should.

Also, when using a model, it usually place my proxy in there and set the idProperty on the model instead of reader.

You may also want to reconsider using id for your store and use storeId for itemId depending on your needs.

Scott.

icebergdelphi
16 Jul 2012, 8:57 AM
Thanks scottmartin (http://www.sencha.com/forum/member.php?165873-scottmartin) but i did not see anything in my header, if i debug with firebug, anything happens, My problem is just with Extjs 4.1.1 , if i switch to extjs 4.0.7 everything works perfect, so my question is: extjs 4.1.1 is missing something or is a big bug?
because my same code works perfectly with extjs 4.0.7, so i wanted upgrade to extjs 4.1.1 but i think is not moment yet.

icebergdelphi
16 Jul 2012, 9:03 AM
Ok scottmartin (http://www.sencha.com/forum/member.php?165873-scottmartin) thanks again i just tested delete record.setId(0); and now everything works perfect with extjs 4.1.1





if (values.IdPrepdetalle > 0){ //Si Hay algun Valor, entra en Modo de Actualizacion
record.set(values);
} else{ //De Lo contrario, si la accion fue para agregar, se inserta un registro
record = Ext.create('Prep.model.Voto.Voto');
record.set(values);
//record.setId(0);// coment this line and get works perfect
this.getVotoVotoStore().add(record);
}
win.close();
:D

icebergdelphi
16 Jul 2012, 9:05 AM
scottmartin (http://www.sencha.com/forum/member.php?165873-scottmartin) Sorry you are the better answer, sorry i just click the wrong answer.:">

scottmartin
16 Jul 2012, 9:22 AM
Fixed ;)

Thanks for the update.

Scott.