I added virtual Detail and after filling the object it displays all records. On not Virtual details recoreds are displayed with amount of 10 and after clicking "Show More" it shows another 10. Bassicaly I want the same logic for my Virtual Detail. I tried to set "RowCount" to 10 but it did not work.
Is it possible to add record limitation as it works in not virtual detail with rowcount 10
define("UsrFinancialAccountsVirtualDetail", ['ContactPageV2' ], function(ContactPageV2) {
return {
entitySchemaName: "UsrFinancialAccountsVirtualObject",
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "LoadGridButton",
"parentName": "Detail",
"propertyName": "tools",
"values": {
"itemType": Terrasoft.ViewItemType.BUTTON,
"caption": {"bindTo": "Resources.Strings.LoadGridButtonCaption"},
"click": {"bindTo": "onLoadGridButtonClick"},
"style": Terrasoft.controls.ButtonEnums.style.TRANSPARENT
},
},
]/**SCHEMA_DIFF*/,
attributes: {
IsGridEmpty: {
dataValueType: this.Terrasoft.DataValueType.BOOLEAN,
value: true
}
},
methods: {
sortColumn: this.Terrasoft.emptyFn,
loadGridData: this.Terrasoft.emptyFn,
getRowCount: function() {
return 10;
},
init: function() {
this.callParent(arguments);
this.set("IsGridEmpty", true);
this.set("IsGridDataLoaded", true);
},
onLoadGridButtonClick: function() {
var _branchVirtualObject = this;
this.set("MaskId", Terrasoft.Mask.show({timeout: 0}));
var baseSecret = Terrasoft.SysSettings.cachedSettings.baseSecret;
var baseUrl = Terrasoft.SysSettings.cachedSettings.baseUrl;
jQuery.ajax({
type: "GET",
url: `**************************************`,
headers: {
"Content-Type": "application/json",
"Accept-Language": "ru-RU"
},
dataType: "json",
success: function(getAccountsResponse) {
if(getAccountsResponse.status.code == 1 && getAccountsResponse.data.accounts){
let accountsData = getAccountsResponse.data.accounts
_branchVirtualObject.parseDataToDetail(accountsData)
_branchVirtualObject.showInformationDialog(getAccountsResponse.status.message)
Terrasoft.Mask.hide(_branchVirtualObject.get("MaskId"));
}else{
_branchVirtualObject.fallbackOnError(getAccountsResponse.status.message)
Terrasoft.Mask.hide(_branchVirtualObject.get("MaskId"));
}
},
error: function(getCardsResponse) {
Terrasoft.Mask.hide(_branchVirtualObject.get("MaskId"));
_branchVirtualObject.fallbackOnError("Error")
},
});
},
fallbackOnError: function(message, response) {
this.hideBodyMask();
this.showInformationDialog(message, null, { style: Terrasoft.MessageBoxStyles.RED });
console.log(message);
},
parseDataToDetail:function(cardsData){
var data =[];
cardsData.map(x => {
const tempObj = {
UsrAccountId: x.accountId,
UsrIndex: x.index,
UsrBalance: x.balance,
UsrStatus: x.status,
UsrCurrency: x.currency,
UsrType: x.type,
UsrBankAccountNumber: x.UsrBankAccountNumber,
} ;
data.push(tempObj)
})
var newCollection = Ext.create("Terrasoft.Collection");
Terrasoft.each(data, function(item, key) {
var model = Ext.create("Terrasoft.BaseViewModel", {
rowConfig: {
UsrId: {
columnPath: "UsrId",
dataValueType: Terrasoft.DataValueType.GUID
},
UsrAccountId: {
columnPath: "UsrAccountId",
dataValueType: Terrasoft.DataValueType.TEXT
},
UsrIndex: {
columnPath: "UsrIndex",
dataValueType: Terrasoft.DataValueType.GUID
},
UsrBalance: {
columnPath: "UsrBalance",
dataValueType: Terrasoft.DataValueType.TEXT
},
UsrStatus: {
columnPath: "UsrStatus",
dataValueType: Terrasoft.DataValueType.TEXT
},
UsrCurrency: {
columnPath: "UsrCurrency",
dataValueType: Terrasoft.DataValueType.TEXT
},
UsrType: {
columnPath: "UsrType",
dataValueType: Terrasoft.DataValueType.TEXT
},
UsrBankAccountNumber: {
columnPath: "UsrBankAccountNumber",
dataValueType: Terrasoft.DataValueType.BOOLEAN
},
},
values: {
UsrId: Terrasoft.generateGUID(),
UsrAccountId: item.UsrAccountId,
UsrIndex: item.UsrIndex,
UsrBalance: item.UsrBalance,
UsrStatus: item.UsrStatus,
UsrCurrency: item.UsrCurrency,
UsrType: item.UsrType,
UsrBankAccountNumber: item.UsrBankAccountNumber,
}
}, this);
newCollection.add(model.get("Id"), model);
});
var response = {
collection: newCollection,
success: true,
errorInfo: undefined,
};
this.set("IsGridLoading", false);
this.set("IsGridDataLoaded", true);
this.set("IsGridEmpty", false);
this.set("IsDetailCollapsed", false);
this.set("RowCount", 10);
this.updateLoadedGridData(response, this.onGridDataLoaded, this);
},
}
};
});