Fotios Kotsiopoulos
Posts: 0
Joined: Mon Dec 08, 2014 9:32 am

Unable to hide empty list items

Hi guys,

My application has a collapsibleset with a number of dynamic lists populated by a REST service. Each list item includes a grid with lables.

Image

When the REST service provide a value for eth_type I'm able to detect the undefined values and reduce the size of the list.

Image

I do so by using the following javascript when mapping label text like eth_type

if (typeof value === "undefined")
{
$(element).parent().parent().parent().hide();
}

Image

The problem I have is that when the service doesn't include any response for some labels, the list is displayed empty.

Image

How can I detect and hide these empty lists?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Unable to hide empty list items

Hello,

You can add next line:

pre$( ":empty" ).hide();/pre

It can hide more elements then expected, just write your selector before :empty

Fotios Kotsiopoulos
Posts: 0
Joined: Mon Dec 08, 2014 9:32 am

Unable to hide empty list items

Hi Alena.

Thanks. I can't get this to work as expected.
Should I apply the JS code with the :empty selector at the success mapping service or is it best to apply it once the service is complete and try to target individual selectors?

Regards,
Fotios

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Unable to hide empty list items

Show us code you use.

Fotios Kotsiopoulos
Posts: 0
Joined: Mon Dec 08, 2014 9:32 am

Unable to hide empty list items

Screenshot attached.

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Unable to hide empty list items

Hello Fotios,

Please try to use the element that comes in
pre$(element).hide();/pre

Fotios Kotsiopoulos
Posts: 0
Joined: Mon Dec 08, 2014 9:32 am

Unable to hide empty list items

Still no luck.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Unable to hide empty list items

Hello!

Please try this one pre$(element).closest("[name=mobilelistitem_767]").hide();/pre

Fotios Kotsiopoulos
Posts: 0
Joined: Mon Dec 08, 2014 9:32 am

Unable to hide empty list items

Thanks,

I managed to work around this by defining default text label for
label_eth_type" of "novalue".

When the service completes I run the following code to hide lists that still include the default "novalue" text for label_eth_type.

$('.DisplayDatapathFlowsPage_label_eth_type:contains("novalue")').parent().parent().parent().hide();

Maybe not the best way of doing things but it works.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Unable to hide empty list items

Hello Fotios,

Thank you for the update.

Return to “Issues”