Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Which datasource method should be used if a user click on already selected record in grid

Posted on by 240

Hi all,

I have a form with multiple datasources in different grids. I am implementing a logic that if a user selects the record in one grid, it should filter the records in another based on the value of a filter control.

I have used the selectionChanged() method for that purpose, so when form open user set the value in filter control and then select any record in the grid, the filter applies in another datasource. but the problem with selectionChanged() method is that they only get called when the user selects a new record. So if I open a form and my datasource has only one record in it, I set the value in filter conrol and then select that one record of the datasource which is already selected, the method wouldn't get called. I have tried with active() method too, it also has the same behaviour.

Can anybody suggest which datasource method should I use when the user selects the already selected record in the form grid?

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Which datasource method should be used if a user click on already selected record in grid

    Just add code in the modified method of the checkbox and apply the filter there, and from the active method of the data source. This way if filter is checked, data is filtered based on the selected method of the data source. This way your user doesn't need to click the record which is already selected to actually get the filtered results. One click less and much more intuitive.

    If user selects another record, filtering will run again. And if user clears the checkbox, your code should clear the filter.

    Makes sense?

  • Hassan Akhtar Khan Profile Picture
    Hassan Akhtar Khan 240 on at
    RE: Which datasource method should be used if a user click on already selected record in grid

    Actually the filter is applied on the selected record value and that filter control I am talking about will just determine that filter should be applied or not. Lets say it is a check box, on selection changed event it will first checks if the check box is checked and then it will apply filter on second datasource based on the some field value in selected datasource.

    So problem will occur if user select the check box to apply filter and then select a record in the first datasource but there is only one record which is already selected, selectionChanged could not be called.

    I have currenlty moved my code in active method, so that user could at least refresh the form after check box is selected. The active method will be called on refreshing the datasource and the filter would be applied.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Which datasource method should be used if a user click on already selected record in grid

    Active is the correct method. My suggestion is to filter the second data source also when the filter is changed, not only when user selects a record on the grid. But this comment is based on limited information.

    Anyway, you can hook in clicked method of the grid, there should be some method that is fired when anything on the grid is clicked. Then get the current record of the data source and you're good to go. But this UX behavior is not used anywhere in the standard system. My recommendation is to align with the logic of the standard system. Filtering something when the filter is modified would seem logical to me, instead of having to click the already selected record in order to trigger the filtering.

    And of course if user selects another record you must filter again.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans