Добрый день,
Возможно ли отфильтровать справочное поле внутри модального окна? Я попробовал обычным путем через атрибуты, но это не сработало, бпм даже не зашла в реализацию "lookupListConfig". В справочнике просто отображались абсолютно все значения
После решил попробовать заполнить справочник вручную нужными значениями
//attributes
"RIBDocType": {
"dataValueType": Terrasoft.DataValueType.ENUM,
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
"caption": "RIBDocType"
},
"documentTypeList": {
"dataValueType": Terrasoft.DataValueType.ENUM,
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
"isCollection": true
}
//diff
{
"operation": "insert",
"parentName": "Header1",
"propertyName": "items",
"name": "RIBDocType",
"values": {
"bindTo": "RIBDocType",
"caption": "Тип документа",
"classes": {"wrapperClass": ["base-edit"]},
"layout": {"column": 0, "row": 3, "colSpan": 24},
"textSize": "Default",
"contentType": Terrasoft.ContentType.ENUM,
"labelConfig": {
"visible": true
},
"controlConfig": {
"className": "Terrasoft.ComboBoxEdit",
"list": {
"bindTo": "documentTypeList"
},
"change": {
"bindTo": "onMyValueChange"
},
"prepareList": {
"bindTo": "prepareDocumentTypeList"
}
}
},
"index": 3
}
//methods
onRender: function() {
if (!this.get("documentTypeList")) {
this.set("documentTypeList", this.Ext.create("Terrasoft.Collection"));
}
},
prepareDocumentTypeList: function(filter, list) {
if (list === null) {
return;
}
list.clear();
var columns = {};
var value1 = {
displayValue: "Type1",
value: "e8670398-603b-43ca-820d-03e5b03fc275"
};
var value2 = {
displayValue: "Type2",
value: "14fcef3a-7d9e-4737-810f-52d57db3673a"
};
var value3 = {
displayValue: "Type3",
value: "672606f8-da25-40bd-a4ef-95c958331743"
};
columns[1] = value1;
columns[2] = value2;
columns[3] = value3;
list.loadAll(columns);
console.log(list);
},
onMyValueChange: function(val) {
if (val && val.displayValue) {
console.log("you pick: ", val.displayValue);
}
},Однако таким образом данные не отображаются в выборке совсем, просто пустой справочник.
Нравится
Сериков Асхат Кайратович,
Вот, например, код страницы с проекта. Если в attributes добавить lookupListConfig для поля Contact, всё подтянется
/*jshint ignore: start*/
define("UsrSchema", [],
function() {
return {
mixins: {},
messages: {},
attributes: {},
details: {},
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "mainBoxContainer",
"values": {
"id": "mainBoxContainer",
"itemType": Terrasoft.ViewItemType.CONTAINER,
"items": []
}
},
{
"operation": "insert",
"name": "mainBoxContainerGrid",
"parentName": "mainBoxContainer",
"propertyName": "items",
"values": {
"itemType": Terrasoft.ViewItemType.GRID_LAYOUT,
"items": []
}
},
{
"operation": "insert",
"parentName": "mainBoxContainerGrid",
"propertyName": "items",
"name": "Contact",
"values": {
"bindTo": "Contact",
"caption": "Контакт",
"contentType": Terrasoft.ContentType.ENUM,
"layout": {
"column": 0,
"row": 0,
"colSpan": 24
}
},
}
]/**SCHEMA_DIFF*/,
methods: {
init: function() {
this.callParent(arguments);
},
getLookupQuery: function(filter, column) {
var esq = this.callParent(arguments);
var lookupListConfig = this.getLookupListConfig(column);
if (lookupListConfig) {
this.Terrasoft.each(lookupListConfig.columns, function(column) {
if (!esq.columns.contains(column)) {
esq.addColumn(column);
}
}, this);
}
var schemaColumn = this.getColumnByName(column);
if (schemaColumn.lookupListConfig && schemaColumn.lookupListConfig.filter) {
esq.filters.addItem(schemaColumn.lookupListConfig.filter());
}
return esq;
},
getLookupListConfig: function(columnName) {
var schemaColumn = this.getColumnByName(columnName);
if (!schemaColumn) {
return null;
}
var lookupListConfig = schemaColumn.lookupListConfig;
if (!lookupListConfig) {
return null;
}
var excludedProperty = ["filters", "filter"];
var config = {};
this.Terrasoft.each(lookupListConfig, function(property, propertyName) {
if (excludedProperty.indexOf(propertyName) === -1) {
config[propertyName] = property;
}
});
return config;
}
}
};
});
/*jshint ignore: end*/
1) Я бы попробовал
columns[value1.value] = value1; columns[value2.value] = value2; columns[value3.value] = value3;
+ в каждом объекте продублировал
var value1 = {
displayValue: "Type1",
name: "Type1",
value: "e8670398-603b-43ca-820d-03e5b03fc275"
};чисто на всякий случай
2) Если это своё модальное окно, не унаследованное от basePage, то придётся копировать логику из getLookupQuery (BasePageV2). Там как раз таки и идёт перебор аттрибутов на фильтры, доп колонки и т.п.
Варфоломеев Данила,
Спасибо, да не наследованное, пойду пробовать
Сериков Асхат Кайратович,
Вот, например, код страницы с проекта. Если в attributes добавить lookupListConfig для поля Contact, всё подтянется
/*jshint ignore: start*/
define("UsrSchema", [],
function() {
return {
mixins: {},
messages: {},
attributes: {},
details: {},
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "mainBoxContainer",
"values": {
"id": "mainBoxContainer",
"itemType": Terrasoft.ViewItemType.CONTAINER,
"items": []
}
},
{
"operation": "insert",
"name": "mainBoxContainerGrid",
"parentName": "mainBoxContainer",
"propertyName": "items",
"values": {
"itemType": Terrasoft.ViewItemType.GRID_LAYOUT,
"items": []
}
},
{
"operation": "insert",
"parentName": "mainBoxContainerGrid",
"propertyName": "items",
"name": "Contact",
"values": {
"bindTo": "Contact",
"caption": "Контакт",
"contentType": Terrasoft.ContentType.ENUM,
"layout": {
"column": 0,
"row": 0,
"colSpan": 24
}
},
}
]/**SCHEMA_DIFF*/,
methods: {
init: function() {
this.callParent(arguments);
},
getLookupQuery: function(filter, column) {
var esq = this.callParent(arguments);
var lookupListConfig = this.getLookupListConfig(column);
if (lookupListConfig) {
this.Terrasoft.each(lookupListConfig.columns, function(column) {
if (!esq.columns.contains(column)) {
esq.addColumn(column);
}
}, this);
}
var schemaColumn = this.getColumnByName(column);
if (schemaColumn.lookupListConfig && schemaColumn.lookupListConfig.filter) {
esq.filters.addItem(schemaColumn.lookupListConfig.filter());
}
return esq;
},
getLookupListConfig: function(columnName) {
var schemaColumn = this.getColumnByName(columnName);
if (!schemaColumn) {
return null;
}
var lookupListConfig = schemaColumn.lookupListConfig;
if (!lookupListConfig) {
return null;
}
var excludedProperty = ["filters", "filter"];
var config = {};
this.Terrasoft.each(lookupListConfig, function(property, propertyName) {
if (excludedProperty.indexOf(propertyName) === -1) {
config[propertyName] = property;
}
});
return config;
}
}
};
});
/*jshint ignore: end*/