Question

Hide Detail when there are no records to display

Hi,

I have read-only detail in "Lead" page where connected records automatically added.

I want to hide the detail completely when there are no records to display in the detail. Please suggest me a way to achieve this.

Like 0

Like

4 comments
Best reply

Hello Indira,

I have the basics outlined here: https://customerfx.com/article/showing-and-hiding-field-groups-or-any-p…

To do this, you'll do something like the following:

1) Add an attribute to the page:

attributes: {
    "IsMyDetailVisible": {
        dataValueType: Terrasoft.DataValueType.BOOLEAN,
        type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
        value: true
    }
}

2) Locate the detail in the diff, then add a visible property in the values part, like this (you can find what the detail is named by looking at the details section in the page code)

{
	"operation": "insert",
	"name": "UsrSchema3Detail34474092",
	"values": {
		"itemType": 2,
		"markerValue": "added-detail",
		"visible": { "bindTo": "IsMyDetailVisible" } 
	},
	"parentName": "Tab3257f6faTabLabel",
	"propertyName": "items",
	"index": 0
},

3) Then, in the onEntityIntialized of the page, you'll need to do an EntitySchemaQuery to read the records from the same entity as the detail (alternatively, you could add code to the detail to send a sandbox message back to the page to tell it to just show/hide as needed based on the number of records loaded). The key is here you need to set the attribute to true or false to show or hide the detail. Something like this:

onEntityInitialized: function() {
    this.callParent(arguments);
 
    var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "UsrMyDetailObject" });
    esq.addColumn("Id");
 
    esq.filters.addItem(
        esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrParentColumn", this.get("Id"))
    );
 
    esq.getEntityCollection(function(result) {
	    this.set("IsMyDetailVisible", result.collection.getItems().length > 0);
    }, this);
}

Ryan

Hello Indira,

I have the basics outlined here: https://customerfx.com/article/showing-and-hiding-field-groups-or-any-p…

To do this, you'll do something like the following:

1) Add an attribute to the page:

attributes: {
    "IsMyDetailVisible": {
        dataValueType: Terrasoft.DataValueType.BOOLEAN,
        type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
        value: true
    }
}

2) Locate the detail in the diff, then add a visible property in the values part, like this (you can find what the detail is named by looking at the details section in the page code)

{
	"operation": "insert",
	"name": "UsrSchema3Detail34474092",
	"values": {
		"itemType": 2,
		"markerValue": "added-detail",
		"visible": { "bindTo": "IsMyDetailVisible" } 
	},
	"parentName": "Tab3257f6faTabLabel",
	"propertyName": "items",
	"index": 0
},

3) Then, in the onEntityIntialized of the page, you'll need to do an EntitySchemaQuery to read the records from the same entity as the detail (alternatively, you could add code to the detail to send a sandbox message back to the page to tell it to just show/hide as needed based on the number of records loaded). The key is here you need to set the attribute to true or false to show or hide the detail. Something like this:

onEntityInitialized: function() {
    this.callParent(arguments);
 
    var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "UsrMyDetailObject" });
    esq.addColumn("Id");
 
    esq.filters.addItem(
        esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrParentColumn", this.get("Id"))
    );
 
    esq.getEntityCollection(function(result) {
	    this.set("IsMyDetailVisible", result.collection.getItems().length > 0);
    }, this);
}

Ryan

Hi Ryan,



Thanks for your outstanding contribution to our community. 



Best regards,

Yurii

Hi Ryan,

 Thanks for the reply. This is really helpful!!

Hi all, we need exactly the same option in Freedom UI? it´s possible?

Show all comments