-
10 Apr 2012 9:53 AM #1
Unanswered: Extraparams and model save
Unanswered: Extraparams and model save
Hi
I was wondering if there is any way to pass an array of objects as extra param of model.save method ?
For simple types params seem to work.
However if I want to send and array as an extra param,(of course I changed server side function to be approperiate ) par variable is an empty list. Here is a code I use to send an model and arrayCode:Ext.define('RightGridModel', { extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, {name: 'rightText', type: 'string'}, {name: 'digit',type:'int'} ] }); var mod = Ext.create('RightGridModel'); mod.set('rightText', 'some text'); mod.save({ url: "Home/Insert", params: { par: 'additional parameter' } });
Is there any way to send a model and an array as extra parameter ?? What is the best way to achieve that ?Code:mod.save({ url: "Home/Insert", params: { par: Ext.encode(array) } });
-
10 Apr 2012 10:13 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Sure, just create the array and send it.
Regards,Code:var myarray = []; myarray.push({ field: value }); rec.save({ params: { mydata: Ext.encode(myarray); } });
Scott
-
10 Apr 2012 12:30 PM #3
Unfortunately it's not working. In the first post I wrote I tried this. To be sure I checked it again, but it still doesnt work
Edit
It only works if I send simple types, like int or string. However sending objects in array is not working
-
10 Apr 2012 12:50 PM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Are you having problems on the server side grabbing the data, or are you saying that the data is not sent? Do you inspect the traffic to the server using Firebug/Developer Tools?
Example:
Regards,Code:params: { sort: '[{"property":"user_name","direction":"ASC"}]' } function get_json_value($json,$key) { $result = NULL; if(function_exists('json_decode')) { $jsonData = json_decode($json, TRUE); $result = $jsonData[0][$key]; } return $result; } $sort = (isset($_POST['sort']) ? $_POST['sort'] : $_GET['sort']); $ord = get_json_value($sort,'property'); $dir = get_json_value($sort,'direction');
Scott.


Reply With Quote