In this article, we will show you how to set a mandatory search filter inside the userview. In this sample case, we will use the Title as the mandatory filter.

Before entering search filter.


After entering search filter.


To start, choose the desired filters for the datalist builder and make sure to identify the URL Request Parameter of the mandatory filter, which in this case is Title.


Now that we have set up the app, we can now proceed to set the Javascript for the mandatory filter.

  1. Go to the Userview Builder
  2. Click on the userview that you want to add the restriction to
  3. Click on the "property" icon on the list that you want to modify
  4. Click on "UI (List)" tab from the breadcrumb
  5. Add the Javascript on the custom footer
Javascript
<script>
    $(document).ready(function(){
	    // Filter form
        filters = $("#filters_test");
        // Filter ID 
        title = $("#d-49700-fn_title"); 
        // Need to give a small delay to allow the page to fully load
        setTimeout(function(){ 
            // Submit button
            btn = filters.find(".waves-button-input")[0]; 
            btn.onclick = function(event){
                if(title.val() == ''){
                    alert("Title must be designated");
                    event.preventDefault();
                }       
            };
        },250); // Increase this value to >1000 if script doesnt run properly
    })
</script>



Download Sample App





  • No labels