Hi, all.
For example, I have two entities linked in many-to-one way:
Person(id@Long, firstname@String, surname@String) and Project(id@Long, name@String, managerId@Long, manager@Person).
Here Project.managerId is a foreignKey to Person.id and Project.manager is a Person object.
Also I have ListGrid of Projects and DynamicForm with Person combobox for addition and editing Project records.
For editing record I show Window and call DynamicForm.editRecord(record).
After that Smartclient pull Person data from server, but all necessary data is at client side already!
So I've got a question. Is it possible use Project.person record for combobox without extra request to the server?
My code is below
For example, I have two entities linked in many-to-one way:
Person(id@Long, firstname@String, surname@String) and Project(id@Long, name@String, managerId@Long, manager@Person).
Here Project.managerId is a foreignKey to Person.id and Project.manager is a Person object.
Also I have ListGrid of Projects and DynamicForm with Person combobox for addition and editing Project records.
For editing record I show Window and call DynamicForm.editRecord(record).
After that Smartclient pull Person data from server, but all necessary data is at client side already!
So I've got a question. Is it possible use Project.person record for combobox without extra request to the server?
My code is below
Code:
isc.DataSource.create({
ID : 'personDS',
dataURL : '/testproject/person',
dataFormat : 'json',
fields : [ {
name : 'id',
type : 'integer',
primaryKey : true,
hidden : true
}, {
name : 'fullName',
type : 'string'
} ],
operationBindings : [ {
operationType : 'fetch',
dataProtocol : 'getParams',
} ]
});
isc.DataSource.create({
ID : 'projectDS',
dataURL : '/testproject/project',
dataFormat : 'json',
fields : [ {
name : 'id',
type : 'integer',
primaryKey : true,
hidden : true
}, {
name : 'name',
type : 'string'
}, {
name : 'managerId',
type : 'integer',
foreignKey : 'personDS.id',
}, {
name : 'manager',
type : 'personDS',
hidden : true
} ],
operationBindings : [ {
operationType : 'fetch',
dataProtocol : 'getParams',
}, {
operationType : 'add',
dataProtocol : 'postParams',
}, {
operationType : 'update',
dataProtocol : 'postParams',
requestProperties : {
httpMethod : 'PUT'
}
} ]
})
isc.defineClass('ProjectWindow', 'Window').addProperties({
width : 300,
height : 300,
autoDraw : true,
initWidget : function() {
this.Super('initWidget', arguments);
this.addItems([ DynamicForm.create({
ID : 'projectDynamicForm',
dataSource : 'projectDS',
useAllDataSourceFields : true,
fields : [ {
name : 'managerId',
editorType : 'ComboBoxItem',
optionDataSource : 'personDS',
displayField : 'fullName',
valueField : 'id',
autoFetch : true,
addUnknownValues : false,
minimumSearchLength : 4,
pickListWidth : 300
} ]
}), Button.create({
title : 'save',
click : function() {
projectDynamicForm.saveData();
}
}) ]);
}
})
VLayout.create({
width : 600,
height : 300,
members : [ Button.create({
title : 'Add',
autoDraw : true,
click : function() {
ProjectWindow.create()
}
}),
ListGrid.create({
autoDraw : true,
dataSource : 'projectDS',
autoFetchData : true,
useAllDataSourceFields : true,
showRecordComponents : true,
showRecordComponentsByCell : true,
fields : [ {
name : 'actions',
} ],
createRecordComponent : function(record, colNum) {
if (colNum == 0) {
return Button.create({
title : 'Edit',
click : function() {
ProjectWindow.create();
projectDynamicForm.editRecord(record)
}
})
}
}
}) ]
})