visibility condition for a web part

merav tg asked on April 18, 2016 09:53

Hi, I’m trying to set a visibility condition for a web part that relays on the outcome of another webpart, more specifically, I would like a webpart to be visible only if the Smart Search Result webpart has no results.

Any Ideas on how to solve this?

Correct Answer

Jan Hermann answered on April 18, 2016 15:14

Macros don't know if your search text returns any results or not. You would need to implement your own macro method that takes the search text from the url and executes our search API to find out if it returns something and then you would return true/false for the Visible field, but it's not a nice solution because you would execute the searching api twice.

A better solution is to clone the search web part and extend it by your logic.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Felix Planjer answered on April 18, 2016 09:59

Maybe you could do this using javascript? Check if the list of results exists and if zo hide or show the other webpart clientside.

0 votesVote for this answer Mark as a Correct answer

merav tg answered on April 18, 2016 10:09

Is there any configuration setting/K# macro i can use instead of Javascript?

0 votesVote for this answer Mark as a Correct answer

Laura Frese answered on April 18, 2016 18:01

Maybe try jQuery

$(function(){
    if($(".mysearch .items").length > 0){
        $(".div-to-show-hide").show();
    } else{
      $(".div-to-show-hide").hide();
    }
});
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.