cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OsmanEsen
Frequent Visitor

Add pre-search filter to a lookup column in a grid

I am currently struggling with a pre-search filter that should be applied to a "Crossing Group" lookup, so the lookup should only displays those 3 Crossing Groups that are added to the grid (marked with green).

OsmanEsen_1-1662028657774.png

I am trying to use the addCustomFilter method, but this cannot be applied to an "attribute" but only to a "control". Are there any ways to add a pre-search filter in a grid column ?. 

My code:


var gridContextRoyaltyTemplate = formContext.getControl("nf_royalty_template_grid");
var royaltyGridRows = gridContextRoyaltyTemplate.getGrid().getRows();
    royaltyGridRows.forEach(function (row, i) {
        var rowEntity  = row.data.entity;
        var crControl = rowEntity.attributes.getByName("nf_crossing_group").getControl("nf_crossing_group");
        var nameValue = crControl.getValue();
        var fetchQuery = "<filter type='and'>" +
        "<condition attribute='nf_contract_rights_in' operator='eq' value='" + contractId + "' />" +
    "</filter>";
       
        crControl.addCustomFilter(fetchQuery);
      });




 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Mira_Ghaly
Dual Super User
Dual Super User

@OsmanEsen 

I am afraid this might not be possible using the PreSearch filter , as per the documentation it is available for formContext not gridContext

https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls...

 

The alternative way would be to do it using a custom PCF control.

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

View solution in original post

2 REPLIES 2
Mira_Ghaly
Dual Super User
Dual Super User

@OsmanEsen 

I am afraid this might not be possible using the PreSearch filter , as per the documentation it is available for formContext not gridContext

https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls...

 

The alternative way would be to do it using a custom PCF control.

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

Thanks for the reply

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (6,349)