I'm currently migrating Extjs 4.2 to Extjs 6.2 and I'm simply trying to save a record. My code works just fine in ExtJs 4.2, but it fails in ExtJs 6.2 when trying to create. The problem is that the value of data changes in Extjs 6.2 after passing it to Model. Please see attached picture.
PICTURE 1:
Take a look at value of data BEFORE hitting the Model (Line 371)
PICTURE 2:
Value of data AFTER hitting the Model (Line 371)
You noticed that the value of data changes. Well this doesn't happen in ExtJs 4.2 and I want it to behave the same way in ExtJs 6.2.
Here's my code:
folder.js
if (folderNameIsValid(s))
{
// create the new folder
var data = {
typeId : me.typeId,
name : s,
loaded : true
};
if (me.clientId) data.clientId = me.clientId;
if (me.userId) data.userId = me.userId;
if (me.recordId) data.recordId = me.recordId;
if (me.empId) data.employeeId = me.empId;
if (pn !== rn) data.parentFolderId = pn.get('folderId');
var node = Ext.create('App.model.FolderTreeNodeDisplay', data);
node.save({
callback : function()
{
pn.appendChild(node);
pn.expand();
sm.select(node);
}
});
}
Here's code for Model:
Ext.define('App.model.FolderTreeNodeDisplay',
{
extend : 'Ext.data.Model',
idProperty: 'folderId',
fields : [
{name: 'folderId', type: 'int', useNull: false},
{name: 'typeId', type: 'int', useNull: true},
{name: 'recordId', type: 'int', useNull: true},
{name: 'employeeId', type: 'int', useNull: true},
{name: 'userId', type: 'int', useNull: true},
{name: 'clientId', type: 'int', useNull: true},
{name: 'permanent', type: 'string', defaultValue: 'N'},
{name: 'fixed', type: 'string', defaultValue: 'N'},
{name: 'active', type: 'string', defaultValue: 'Y'},
{name: 'name', type: 'string', convert: Ext.htmlDecode},
{name: 'parentFolderId', type: 'int', useNull: true},
// domain fields
{name: 'createdBy', type: 'string', persist: false},
{name: 'creationDate', type: 'date', dateFormat: 'c', useNull: true, persist: false},
{name: 'lastUpdatedBy', type: 'string', persist: false},
{name: 'lastUpdatedDate', type: 'date', dateFormat: 'c', useNull: true, persist: false},
// node fields
{name: 'iconCls', type: 'string', persist: false},
{name: 'leaf', persist: false},
{name: 'expanded', persist: false},
{name: 'parentId', persist: false}
],
proxy: {
type: 'rest',
api: {
create : '/rs/rest/folder/create'
},
reader: {
rootProperty: 'data'
}
}
});
My question is: What do I need to change/update in my Model so the value of data remains the same after hitting Line 371 and NOT pull all of the random data that you see in picture 2
Any ideas on what I'm missing or need to change in my Model? Thank you so much in advance!
You haven't specified a URL for the proxy. The default in the framework is to use the model name.