PDA

View Full Version : RemoteComboBox sends empty field value



catequil
8 May 2014, 10:03 PM
Hi, I'm trying to build an example app from an excelent tutorial (http://existdissolve.com/category/javascript/ext/extjs-4-2-app-walkthrough/) and I'm stuck in one detail of a form. Pleeeease help !!, I searched this issue and found many solutions but none of them seems to fix it.I'm using Sencha Cmd 4 (with the MVC ), Ext JS 4.2, and PHP (Yii Framework) in the server, every data interchange between Ext JS and PHP is JSON, I've made a couple of examples of a remote loaded combobox and it works fine, but in this particular form it seems that none of the relational fields is sent to the server when I save the data.Second, the problem, this app is to manage the inventory of cars and the related information, like model, year, make, color, etc., the combobox loads the correct values to select, but when I save the form, the fields that handle the relational data is sent blank, I've checked with Firebug, it generates something like this when I try to save a selling car form:
http://192.168.183.136/CarTracker/index.php?r=Car/create&_dc=1399612977677&records={ "CreatedDate": null, "Active": true, "CarID": null, "Description": "test", "Year": 1925, "ListPrice": 25000, "SalePrice": 26000, "AcquisitionDate": "2014-05-29T00:00:00", "SaleDate": "2014-05-22T00:00:00", "IsSold": false, "StatusName": "", "MakeCountry": "", "ModelName": "", "CategoryName": "", "SalesPeople": [ 2 ], "ColorID": 0, "Features": []}&callback=Ext.data.JsonP.callback8This is the model of the Car:
/** * Model representing a Car object */Ext.define('CarTracker.model.Car', { extend: 'CarTracker.model.Base', idProperty: 'CarID', fields: [ // id field { name: 'CarID', type: 'int', useNull : true }, // simple values { name: 'Description', type: 'string' }, { name: 'Year', type: 'int' }, { name: 'ListPrice', type: 'int' }, { name: 'SalePrice', type: 'int' }, { name: 'AcquisitionDate', type: 'date', dateWriteFormat: 'Y-m-d' }, { name: 'SaleDate', type: 'date', dateWriteFormat: 'Y-m-d' }, { name: 'IsSold', type: 'boolean' }, // relational properties { name: 'StatusName', type: 'auto' }, { name: 'MakeCountry', type: 'auto' }, { name: 'ModelName', type: 'auto' }, { name: 'CategoryName', type: 'auto' }, { name: 'SalesPeople', type: 'auto' }, { name: 'ColorID', type: 'int' }, { name: 'Features', type: 'auto' } ] });This is the store:
/** * Store for managing cars */Ext.define('CarTracker.store.Cars', { extend: 'CarTracker.store.Base', alias: 'store.cars', requires: [ 'CarTracker.model.Car' ], restPath: 'http://192.168.183.136/CarTracker/index.php?r=Car', storeId: 'Cars', model: 'CarTracker.model.Car'});This is the base store from the Ext Car store extends from:
/** * Base {@link Ext.data.Store} from which all other application stores will extend */Ext.define('CarTracker.store.Base', { extend: 'Ext.data.Store', requires: [ 'CarTracker.proxy.JSON' ], /** * @cfg {String} restPath End point for store requests */ restPath: null, //accion: null, constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ storeId: 'Base', remoteSort: true, remoteFilter: true, remoteGroup: true, proxy: { type: 'basejson', url: me.restPath, api: { create: me.restPath + '/create', read: me.restPath, update: me.restPath + '/update', destroy: me.restPath + '/delete' } } }, cfg)]); }})This is the (simplyfied) tab that loads in the Cars form:
/** * Car Tab */Ext.define('CarTracker.view.car.edit.tab.Detail', { extend: 'Ext.panel.Panel', alias: 'widget.car.edit.tab.detail', layout: 'form', initComponent: function() { var me = this; Ext.applyIf(me, { items: [ { xtype: 'fieldset', title: 'Car Info', defaults: { layout: 'hbox', margins: '0 10 0 10' }, items: [ { xtype: 'fieldcontainer', items: [ { xtype: 'ux.form.field.remotecombobox', name: 'Make', fieldLabel: 'Make Country', displayField: 'Country', valueField: 'MakeID', store: { type: 'makes' }, plugins: [ { ptype: 'cleartrigger' } ], editable: false, forceSelection: true }, { xtype: 'ux.form.field.remotecombobox', name: 'Model', fieldLabel: 'Model Name', displayField: 'Name', valueField: 'ModelID', store: { type: 'models' }, plugins: [ { ptype: 'cleartrigger' } ], editable: false, forceSelection: true }, { xtype: 'ux.form.field.remotecombobox', name: 'Status', fieldLabel: 'Status: ', displayField: 'LongName', valueField: 'StatusName', store: { type: 'option.status' }, plugins: [ { ptype: 'cleartrigger' } ], editable: false, forceSelection: true } ] }, { xtype: 'fieldcontainer', items: [ { xtype: 'numberfield', name: 'Year', fieldLabel: 'Year', minValue: 1920 }, { xtype: 'ux.form.field.remotecombobox', name: 'Category', fieldLabel: 'Category', displayField: 'LongName', valueField: 'CategoryID', store: { type: 'option.category' }, plugins: [ { ptype: 'cleartrigger' } ], editable: false, forceSelection: true }, { xtype: 'ux.form.field.remotecombobox', name: 'Color', fieldLabel: 'Color', displayField: 'LongName', valueField: 'ColorID', store: { type: 'option.color' }, plugins: [ { ptype: 'cleartrigger' } ], editable: false, forceSelection: true } ] } ] } ] }); me.callParent(arguments); }});I have the car controller but I dont know if is usefull to put it here (it's quite large).The server response (PHP) for the Color field (for example) it's like follows:
Ext.data.JsonP.callback2({ "registros": [ { "ColorID": "1", "LongName": "Red", "ShortName": "Red", "CreatedDate": "2014-04-25 00:00:00", "Active": "1" }, { "ColorID": "2", "LongName": "Blue", "ShortName": "Blue", "CreatedDate": "2014-04-25 00:00:00", "Active": "1" }, { "ColorID": "3", "LongName": "Orange", "ShortName": "Orange", "CreatedDate": "2014-04-25 00:00:00", "Active": "1" }, { "ColorID": "4", "LongName": "Acid green", "ShortName": "Acid", "CreatedDate": "2014-04-25 00:00:00", "Active": "1" }, { "ColorID": "5", "LongName": "Aero", "ShortName": "Aero", "CreatedDate": "2014-04-25 00:00:00", "Active": "1" } ], "total": "30"});I attach a couple of images to see if its helpfull. Thanks in advance.Regards

mitchellsimoens
19 May 2014, 8:14 AM
Can you format your code so it's legible?

catequil
16 Jul 2014, 9:45 AM
mitchellsimoens, thank you for taking time to check my problem, acctually I solved it by my self, was a simple mistake, I didnt put the name of the field like the one in my model, I'm really new on this and I'm making silly mistakes.