PDA

View Full Version : Ext.Direct store create doesn't pass any params



666ragez666
26 Apr 2010, 1:15 AM
Hello guys,

just a quick question, we might have done some mistakes but I am not really sure.

If you use this sample, you will see that Ext.Direct doesn't pass any parameters on the XHR call for creating the new record, how comes it doesn't the record content ?

You can see the screenshot (http://farm4.static.flickr.com/3012/4553599141_a33362f0d0_o.png) of firebug.

Thanks for your help.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stateful Array Grid Example</title>

<!-- ** CSS ** -->
<!-- base library -->
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!-- overrides to base library -->

<!-- page specific -->
<link rel="stylesheet" type="text/css" href="../shared/examples.css" />
<link rel="stylesheet" type="text/css" href="grid-examples.css" />

<style type=text/css>
/* style rows on mouseover */
.x-grid3-row-over .x-grid3-cell-inner {
font-weight: bold;
}
</style>

<!-- ** Javascript ** -->
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>

<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="../../ext-all.js"></script>

<!-- overrides to base library -->

<!-- page specific -->
<script type="text/javascript">
Ext.onReady(function(){
Ext.app.REMOTING_API = {"url":"php\/router.php","type":"remoting","actions":{"Profile":[{"name":"read","len":1},{"name":"update","len":1},{"name":"create","len":1},{"name":"destroy","len":1}]}};

Ext.Direct.addProvider(Ext.app.REMOTING_API);
var store = new Ext.data.DirectStore({
remoteSort: true,
autoload: true,
autoSave: true,
root: 'calc',
totalProperty: 'total',
idProperty: 'id',
fields: ['id', 'name'],
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: true
}),
api: {
read: Profile.read,
create: Profile.create,
update: Profile.update,
destroy: Profile.destroy
},
sortInfo: {
field: 'id',
direction: 'asc'
}
});

store.load();
var Employee = Ext.data.Record.create([{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}]);
var e = new Employee({
id: 0,
name: '[email protected]'
});
store.insert(0,e);



});


</script>

</head>
<body>

</body>
</html>

Stju
26 Apr 2010, 1:18 AM
Look at serverside code! Do you have read, create e.t.c functions defined and with correct amount of parameters?
It's the first thing to check for, if some parameters are not passed or they amount is wrong!

Also check this and compare, some things are missing...


// Store Writer
this.storeWriter = new Ext.data.JsonWriter({
encode: false
});

// Direct Store
this.prefStore = new Ext.data.DirectStore({
api: {
read: preferencesEditorDIRECT.readData,
create: preferencesEditorDIRECT.createData,
update: preferencesEditorDIRECT.updateData,
destroy: preferencesEditorDIRECT.removeData
},
paramOrder: ['sort','dir','start','limit','fields','query'],
autoLoad : true,
autoSave: true, // <- INPORTANT to send data automatically to server!
batchSave: false,
prettyUrls: false,

writer: this.storeWriter,

root: 'data',
idProperty: 'id',
totalProperty: 'total',
successProperty: 'success',
paramsAsHash: false, //important

paramsNames: { start : 'start', limit : 'limit', sort : 'sort', dir : 'dir'},
remoteSort: true,
baseParams: {
start : 0, // jabut INT!
limit : 20, // jabut INT!
sort : 'pref_name',
dir : 'ASC'
},
fields: [
{ name: 'id', type: 'int'},
.. field names! ..
],
listeners : {
loadexception : function()
{
alert('Store LOAD EXCEPTION! Please restart Your browser');
},
update : function()
{
this.store.commitChanges();
},
scope:this
}
});

Matthias_WB
10 Aug 2011, 11:16 AM
Hello!


Look at serverside code! Do you have read, create e.t.c functions defined and with correct amount of parameters?
It's the first thing to check for, if some parameters are not passed or they amount is wrong!

Can you post the correct server-parameters??? Ihave the same probles as the thread-starter...