Добрый день!
Хочу отобразить коллекцию в деталь, без сохранения в бд.
Есть коллекция Collection состоящая из полей из разных обьектов, мне удалось ее заполнить данными, но столкнулся с проблемой при заполнении через this.getGridData(), который переопределил, при вызове деталь не заполняется данными.
entitySchemaName: "AllParentImplementationsByService" - обьект с проставленным Поведение->виртуальный, думал это поможет но нет
Как корректно сделать вставку этой коллекции в GridData детали?
Предоставляю мою схему детали :
define("AllParentImplementationsByService_Detail", [
"ConfigurationGrid",
"ConfigurationGridGenerator",
"ConfigurationGridUtilities",
"ProcessModuleUtilities"
],
function (
ProcessModuleUtilities
) {
return {
entitySchemaName: "AllParentImplementationsByService",
modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
mixins: {
ConfigurationGridUtilites: "Terrasoft.ConfigurationGridUtilities",
},
businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
attributes: {
IsGridEmpty: {
dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
value: true
},
/**
* Grid data collection.
* @type {Terrasoft.BaseViewModelCollection}
*/
Collection: {
dataValueType: Terrasoft.DataValueType.COLLECTION,
value: this.Ext.create("Terrasoft.BaseViewModelCollection")
},
CaseId: {
dataValueType: Terrasoft.DataValueType.GUID,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "Id"
},
CaseNumber: {
dataValueType: Terrasoft.DataValueType.TEXT,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "CaseNumber" // Номер
},
CaseSymptoms: {
dataValueType: Terrasoft.DataValueType.TEXT,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "CaseSymptoms" //Описание
},
TcName: {
dataValueType: Terrasoft.DataValueType.TEXT,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "TcName" // Тех.карта процесса
},
AccountAddress: {
dataValueType: Terrasoft.DataValueType.TEXT,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "AccountAddress" // Адрес контрагента
},
CasereatedOn: {
dataValueType: Terrasoft.DataValueType.DATE_TIME,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
caption: "CasereatedOn" // Дата регистраци
}
},
messages: {},
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
methods: {
init: function () {
this.callParent(arguments);
this.callAllParentImplementationsByServiceProvisionService();
},
onEntityInitialized: function () {
this.callParent(arguments);
},
callAllParentImplementationsByServiceProvisionService: function () {
this.showBodyMask({
caption: "callAllParentImplementationsByServiceProvisionService"
});
let config = this.getAllParentImplementationsByServiceProvisionServiceConfig();
this.callService(config, this.allParentImplementationsByServiceProvisionServiceHandler, this);
},
getAllParentImplementationsByServiceProvisionServiceConfig: function () {
return {
serviceName: "AllParentImplementationsByServiceProvisionService",
methodName: "GetAllParentImplementationsByServiceProvision",
timeout: 300000,
data: {
Id: this.$MasterRecordId
}
};
},
allParentImplementationsByServiceProvisionServiceHandler: function (response) {
this.hideBodyMask();
var result = JSON.parse(response);
var resultCollection = Ext.create("Terrasoft.BaseViewModelCollection");
for (var i = 0; i < result.length; i++) {
if (!result[i].ExeptionMsg) {
const casereatedOnStr = result[i].CasereatedOn;
const timestamp = parseInt(casereatedOnStr.substring(
casereatedOnStr.indexOf('(') + 1, casereatedOnStr.indexOf(')')));
const date = new Date(timestamp);
const options = { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute:'2-digit' };
const formattedDate = date.toLocaleString(options);
var resultViewModel = Ext.create("Terrasoft.BaseViewModel", {
values: {
"CaseId": result[i].CaseId,
"Number": result[i].CaseNumber,
"Symptoms": result[i].CaseSymptoms,
"Name": result[i].TcName,
"AccountAddress": result[i].AccountAddress,
"CasereatedOn" : formattedDate
}
});
resultCollection.add(resultViewModel);
} else {
const casereatedOnStr = result[i].CasereatedOn;
const timestamp = parseInt(casereatedOnStr.substring(
casereatedOnStr.indexOf('(') + 1, casereatedOnStr.indexOf(')')));
const date = new Date(timestamp);
const options = { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute:'2-digit' };
const formattedDate = date.toLocaleString(options);
var resultErrViewModel = Ext.create("Terrasoft.BaseViewModel", {
values: {
"CaseId": result[i].CaseId,
"CaseNumber": result[i].CaseNumber,
"CaseSymptoms": result[i].CaseSymptoms,
"TcName": result[i].TcName,
"AccountAddress": result[i].AccountAddress,
"CasereatedOn": formattedDate,
"ExeptionMsg": result[i].ExeptionMsg
}
});
resultCollection.add(resultErrViewModel);
}
}
this.set("IsGridEmpty", false);
this.set("Collection", resultCollection);
this.getGridData();
},
getGridData: function () {
return this.get("Collection");
},
useVirtualRecord: function () {
return true;
},
/**
* @inheritDoc BaseGridDetailV2#getCopyRecordMenuItem
* @override
*/
getCopyRecordMenuItem: this.Terrasoft.emptyFn,
/**
* @inheritDoc BaseGridDetailV2#getEditRecordMenuItem
* @override
*/
getEditRecordMenuItem: this.Terrasoft.emptyFn,
/**
* @inheritDoc BaseGridDetailV2#getDeleteRecordMenuItem
* @override
*/
getDeleteRecordMenuItem: Terrasoft.emptyFn,
/**
* @inheritDoc BaseGridDetailV2#getAddRecordButtonVisible
* @override
*/
getAddRecordButtonVisible: function () {
return false;
},
getAddTypedRecordButtonVisible: function () {
return false;
},
getDetailCaption: function () {
return this.get("Resources.Strings.AllParentImplementationsByServiceDetailLabel");
}
},
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "Container",
"parentName": "Header",
"propertyName": "items",
"values": {
"itemType": this.Terrasoft.ViewItemType.CONTAINER,
"layout": { "column": 0, "row": 0, "colSpan": 24 },
"items": []
}
},
{
"operation": "merge",
"name": "DataGrid",
"parentName": "Container",
"propertyName": "items",
"values": {
//"generator": "Terrasoft.GridGenerator.generateGrid",
"itemType": this.Terrasoft.ViewItemType.GRID,
"type": this.Terrasoft.GridType.LISTED,
"collection": "Collection",
"isEmpty": { "bindTo": "IsGridEmpty" },
"captionsConfig": []
}
},
{
operation: "insert",
name: "InfoButton",
parentName: "ActionButtonsContainer",
propertyName: "items",
values: {
click: { bindTo: "callAllParentImplementationsByServiceProvisionService" },
itemType: this.Terrasoft.ViewItemType.BUTTON,
style: this.Terrasoft.controls.ButtonEnums.style.GREEN,
hint: { bindTo: "showHint" },
caption: "Test",
},
},
]/**SCHEMA_DIFF*/
};
});