PDA

View Full Version : Submit parameters empty [3.1]



ruso
18 Jan 2010, 4:49 AM
Hi there, I'm dealing with a grid with row editor and Direct all in ExtJs 3.1... My problem is that for "update, create and delete" the data parameter is always empty. Not sure where the problem is!


{"action":"distribuidora_api","method":"edit","data":[],"type":"rpc","tid":4}

My grid code is:


Ext.namespace('Ebowe'); //define namespace with some 'name'

Ebowe.distribuidoras = function()
{
/*--Private Properties--*/
var moduleItem = 'distribuidora';
var moduleTitle = 'Distribuidoras';

var mainGrid;
var main_store;
var main_cm;

var fm = Ext.form;

function inicio()
{
dataStoreWriter = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});

main_store = new Ext.data.DirectStore({
paramsAsHash:true,
//autoLoad: true,
autoSave: true,
writer: dataStoreWriter,
root: 'datos',
idProperty: 'id',
totalProperty: 'totalCount',
paramOrder: ['start','limit'],
baseParams: {
start: 0,
limit: 100
},
successProperty : 'success',
messageProperty : 'message',
fields: [{
name: 'id',
type: 'int'
},
'distribuidora'],
api: {
read: distribuidora_api.listado,
create: distribuidora_api.add,
destroy: distribuidora_api.remove,
update: distribuidora_api.edit
}
});

var Distribuidora = Ext.data.Record.create([{
name: 'distribuidora',
type: 'string'
}]);

// *************************************
// MAIN CM:
// *************************************
main_cm = new Ext.grid.ColumnModel([{
header: "Id",
dataIndex: 'id',
width: 20,
sortable: true,
hidden: false
},{
header: "Distribuidora",
dataIndex: 'distribuidora',
width: 100,
align: 'left',
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
}
]);

var editor = new Ext.ux.grid.RowEditor({
saveText: 'Actualizar'
});

// *************************************
// MAIN GRID:
// *************************************
mainGrid = new Ext.grid.GridPanel({
border:false,
closable:true,
id: 'distribuidoras_module_cmp',
title: moduleTitle,
plugins: [editor],
ds: main_store,
cm: main_cm,
viewConfig: {
forceFit:true
},
autoExpandColumn: 'email',
loadMask: true,
tbar:[{
text:'Reload',
tooltip:'Recargar la informaciĆ³n de la tabla',
iconCls:'brefresh',
handler: function () {
main_store.reload();
}
},'-',
{
text:'Nuevo',
id: 'users_module_bto_add_referente',
tooltip:'Agregar un nuevo item',
iconCls:'badd',
handler: function(){
var e = new Distribuidora({
distribuidora: 'Nuevo Item'
});
editor.stopEditing();
main_store.insert(0, e);
mainGrid.getView().refresh();
mainGrid.getSelectionModel().selectRow(0);
editor.startEditing(0);
}
},'-',
{
text:'Eliminar',
id: 'main_bto_delete_' + moduleItem,
tooltip:'Eliminar el item seleccionado',
iconCls:'bremove',
disabled: true,
handler: function () {
editor.stopEditing();
var s = mainGrid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
main_store.remove(r);
}
}
}
],
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: main_store,
displayInfo: true,
displayMsg: 'Mostrando del {0} al {1} de {2}',
emptyMsg: "No hay items para mostrar"
})
})

mainGrid.on('rowclick', function(grid, rowIndex, e)
{
Ext.getCmp('main_bto_delete_' + moduleItem).enable();
});


main_store.load({params:{start:0}});
Ext.getCmp('tabs').add(mainGrid).show();

}; // End function grid;

/*--Public Area--*/
return {

init: function()
{
var temp = Ext.getCmp('distribuidoras_module_cmp');
if(!temp){
inicio();
}
else
Ext.getCmp('tabs').setActiveTab('distribuidoras_module_cmp');
}
}
}();

My api.js code is:



Ext.app.REMOTING_API = {"url":"\/assets\/api\/extjs\/router.php","type":"remoting","actions":{"pelicula_api":[{"name":"add","len":2,"formHandler":true},{"name":"edit","len":2,"formHandler":true},{"name":"listado","len":1}],"distribuidora_api":[{"name":"add","len":2},{"name":"edit","len":2},{"name":"remove","len":1},{"name":"listado","len":2}]}};

mdelmarter
18 Jan 2010, 2:05 PM
I have the same issue - the baseParams seem to be being ignored in 3.1

mdelmarter
18 Jan 2010, 2:25 PM
This fix is found here:
http://www.extjs.com/forum/showthread.php?t=88273&highlight=setbaseParam&page=2

cerad
18 Jan 2010, 2:52 PM
Mine seem to work just fine under 3.1.1-beta as well as 3.1.0. Just need to set encode:false per the api documentation. No patch needed.

ruso
18 Jan 2010, 5:47 PM
Mine seem to work just fine under 3.1.1-beta as well as 3.1.0. Just need to set encode:false per the api documentation. No patch needed.

You where right... hahaha, it was so easy!!! THANKS!!!!

encode : Boolean
true to encode the hashed data. Defaults to true. When using Ext.data.DirectProxy, set this to false since Ext.Direct.JsonProvider will perform its own json-encoding. In addition, if you're using Ext.data.HttpProxy, setting to false will cause HttpProxy to transmit data using the jsonData configuration-params of Ext.Ajax.request instead of params. When using a Ext.data.Store.restful Store, some serverside frameworks are tuned to expect data through the jsonData mechanism. In those cases, one will want to set encode: false, as in let the lower-level connection object (eg: Ext.Ajax) do the encoding.