Hide Content panels with empty queries

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
JoshK131
Posts: 31
Joined: Tue Jan 26, 2021 11:09 pm

Hide Content panels with empty queries

Post by JoshK131 »

Hello,

I have a visual perspective set up with multiple content panels displaying queries.

To clear clutter, I would like to completely hide the queries which do not display any records.

I've been trying out render scripts on the content panels but it is not working.
The error I am getting is: Exception running render script for panel BAS_FRAME_main_HTMA_Request_Panel2 TypeError: Cannot read properties of undefined (reading 'wrapperId')

Code: Select all

var grid = $("#" + parser.m_widgetInfo.wrapperId).find(".k-grid").data("kendoGrid");
console.log("grid found");
grid.bind("dataBound", expand);
console.log("script end");

function expand(e) {

console.log("enter function");

console.log(grid.dataSource.total());
if (grid.dataSource.total() == 0 ){
    //Hide grid

console.log("total empty");
      $(grid).hide();
    }
    else{
      //Show grid
console.log("total visible");
      $(grid).show();
    }
}
How shall I solve this problem?
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Hide Content panels with empty queries

Post by joben »

This is how we do it:
conditional.png
conditional.png (65.15 KiB) Viewed 1477 times
Instead of using "Display results of query", use "Display results of process".

Then make your process like this:

Code: Select all

If COUNT YourBoName >0 Then
DISPLAY 'Name of your query'
Or you could use EXISTS :

Code: Select all

If EXISTS YourBoName WHERE (YourBoName.Name CONTAINS 'John') Then
DISPLAY 'Name of your query'
If nothing is found, the content panel will be empty.

I think this method is awesome and we use it alot. It makes the start page really clean, and the important stuff will always be visible.
Regards, Joakim

Image
JoshK131
Posts: 31
Joined: Tue Jan 26, 2021 11:09 pm

Re: Hide Content panels with empty queries

Post by JoshK131 »

Brilliant,

Nice solution, no need for javascript.

Thank you very much
Post Reply