Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Unanswered

Delete blank pages with javascript

(0) ShareShare
ReportReport
Posted on by 312

Hi community, I am having the following problem. It happens that I implement a filter with javascript to show me only certain data.

The code is the following:

 

$(document).ready(function () {
 
 var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);

 list.on("loaded", function () {
 
 var IdListaPrecio = "{{user.crd4f_listaprecios}}";
 console.log("IdListaPrecio: " + IdListaPrecio);
 
 if (IdListaPrecio == IdListaPrecio) {
 list.find("table tbody > tr").each(function (index, value) {
 var tr = $(this);
 var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("data-value");
 
 if (tipos != IdListaPrecio) {
 console.log("Tipos: " + tipos);
 $(tr).remove(); 
 }
 });
 }
 });

});

 

 

However, when performing this procedure it shows me the result of the filter between all the pages. For example, the first page does not show me any data:

MartinVargas_0-1639694177407.png

In this example, the results of my filter start to appear until page number 3:

MartinVargas_1-1639694208659.png

 

Is there a way to remove a blank page through javascript?. Or is there some way to solve this?

 

Can anybody help me out here please?

Cheers folks

  • MartinVargas Profile Picture
    312 on at
    Re: Delete blank pages with javascript

    @Soundharya, unfortunately 😞 . Is there a way?

  • soundharya Profile Picture
    249 on at
    Re: Delete blank pages with javascript

    Ya even i tried this , unfortunately this code runs on each page not on all records may be you don't have the data or check on next pages for matching data

    i have one record matching in 1st page and other in 2nd page

     

    Soundharya_0-1641315897453.pngSoundharya_1-1641315926615.png

     

  • MartinVargas Profile Picture
    312 on at
    Re: Delete blank pages with javascript

    Hi @Soundharya. This is literally all the code.

     

     

    $(document).ready(function () {
     
     var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);
    
     list.on("loaded", function () {
     
     var IdListaPrecio = "{{user.crd4f_listaprecios}}";
     console.log("IdListaPrecio: " + IdListaPrecio);
     
     
     list.find("table tbody > tr").each(function () {
     var tr = $(this);
     var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("aria-label");
     
     if (tipos != IdListaPrecio) {
     console.log("Tipos: " + tipos);
     $(tr).remove(); 
     }
     });
     
     });
    
    });

     

     

    I got it based on Oliver Rodrigues's exercise: https://oliverrodrigues365.com/2021/01/24/power-apps-portals-custom-lookup-filter/

     

  • soundharya Profile Picture
    249 on at
    Re: Delete blank pages with javascript

    first line there was mistake 2 dots

    var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);

    we are trying to remove the row there is no way it will get added, is there any other code on this?
    can you paste full code?

    i have done the same it is working for me  

  • MartinVargas Profile Picture
    312 on at
    Re: Delete blank pages with javascript

    Hi @Soundharya, By implementing the following code:

    $(document).ready(function () {
     
     var list = $("#crd4f_clavearticuo_lookupmodal")..find(".entity-lookup").find(".entity-grid").eq(0);
    
     list.on("loaded", function () {
     
     var IdListaPrecio = "{{user.crd4f_listaprecios}}";
     console.log("IdListaPrecio: " + IdListaPrecio);
     
     
     list.find("table tbody > tr").each(function () {
     var tr = $(this);
     var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("aria-label");
     
     if (tipos != IdListaPrecio) {
     console.log("Tipos: " + tipos);
     $(tr).remove(); 
     }
     });
     
     });
    
    });

    It keeps showing me blank pages:

    MartinVargas_0-1641236443757.png

     

     

  • soundharya Profile Picture
    249 on at
    Re: Delete blank pages with javascript

    Both are text fields right then above code should work can you try once, i have modified few

  • MartinVargas Profile Picture
    312 on at
    Re: Delete blank pages with javascript

    Hi @Soundharya.

    The data type "$(tr).find('td[data-attribute="crd4f_idlistprices"]').attr("data-value");" is Text.

     

    Here: "types != PriceListId" I am comparing all the list types in the crd4f_priceidlist column against the list type associated with the user.

  • soundharya Profile Picture
    249 on at
    Re: Delete blank pages with javascript

     

    Hi,

    try below code

    What is the data type of this crd4f_idlistaprecios

    $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("data-value");
    and what are you comparing here tipos != IdListaPrecio
    if you are comparing text then it should be as below
    $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("
    aria-label");

     

    $(document).ready(function () {
     
     var list = $("#crd4f_clavearticuo_lookupmodal")..find(".entity-lookup").find(".entity-grid").eq(0);
    
     list.on("loaded", function () {
     
     var IdListaPrecio = "{{user.crd4f_listaprecios}}";
     console.log("IdListaPrecio: " + IdListaPrecio);
     
     
     list.find("table tbody > tr").each(function () {
     var tr = $(this);
     var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("data-value");
     
     if (tipos != IdListaPrecio) {
     console.log("Tipos: " + tipos);
     $(tr).remove(); 
     }
     });
     
     });
    
    });

     

     

  • MayankP Profile Picture
    462 on at
    Re: Delete blank pages with javascript

    Hi @MartinVargas 

     

    my suggestion is to use Add pre-search on relevant look up filed to filter data displayed in look up view...

     

    Refer following example article for this..

    https://www.inogic.com/blog/2015/08/apply-custom-filter-on-lookup-field-in-dynamic-crm-using-script/

     

     

     

    https://mayankp.wordpress.com/2021/08/11/dynamics-365-setting-up-owner-look-up-to-display-only-teams-related-to-logged-on-user/

     

     

     

  • Christian Leverenz Profile Picture
    1,214 on at
    Re: Delete blank pages with javascript

    Hi @MartinVargas ,

    no answer, but could it be, that this is the mobile view and the data is split up intop several single "pages"? 

    When you remove the pagecontent i would assume, that the pagenavigation is not removed. So, i assume that you also have to remove the corresponding buttons when you remove a specific entry which you do not want to see.

     

    If the attribute you are filtering on is a lookup, there is an easier way to filter the stuff: just place the lookup on the form, too and choose in the lookup you want to filter "only related records" and choose the right relation. Then only related records are shown. (you may hide the lookup on the form by js)

     

    Ah, you are filtering over a user attribute. When the user should only see valid entries for hers/his user you might conider an entitytablepermission for that. Just create one in contact scope for the targettable which only selects entities which are allowed and assigned it to an appropiate role.

     

    Just a couple of ideas, may be it helps.

    Have fun,

      Christian

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35