Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load records for grid using data provider #3103

Open
1 task done
teowave opened this issue Jan 19, 2024 · 3 comments
Open
1 task done

load records for grid using data provider #3103

teowave opened this issue Jan 19, 2024 · 3 comments
Labels
new feature New feature or request scope: toolpad-studio Abbreviated to "studio"

Comments

@teowave
Copy link

teowave commented Jan 19, 2024

Duplicates

  • I have searched the existing issues

Summary

I am trying to load records for grid using data provider. But in my case i need to add additional filter values from external ui components.
I found a way to do that by storing them in js file properties that hold data provider logic. But i cant find a way to trigger data provider reload in this case, when my external component filter values change.
Is there any ways to do that?

Alternatively i can use direct rows source but then i dont know how to grab grid paging values. Maybe this have easier solution?
Thanks.

Examples

No response

Motivation

No response

Search keywords:

@teowave teowave added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 19, 2024
@Janpot
Copy link
Member

Janpot commented Jan 22, 2024

This currently isn't possible yet as all state related to filtering is localized to the datagrid. I see two potential ways we can move forward with this.

  1. We expose the filter model as state on the datagrid and expose onChange/onCommit events on the form components. This will allow you to update the filter model programmatically.
  2. We move the data provider concept at the page level, just like queries/actions and let it hold the filter state. We add UI that lets you bind page state to filter model items. This essentially creates global filter model state and is very similar to how queries/actions already work. I'm slightly more inclined towards this solution. I'll try to write up a feature request for this idea this week.

@Janpot Janpot added new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 22, 2024
@teowave
Copy link
Author

teowave commented Jan 22, 2024

Thank you for the quick reply and for the attention given to this issue.

Generally I think server-side filtering, like data provider is doing, is an excellent idea - it solves a lot of security and roles and permissions issues, enabling simpler code and system design. However we of course need to have a way to transfer state from the page to the server, as you mentioned in your response

@MBilalShafi
Copy link
Member

MBilalShafi commented Feb 15, 2024

This currently isn't possible yet as all state related to filtering is localized to the datagrid. I see two potential ways we can move forward with this.

  1. We expose the filter model as state on the datagrid and expose onChange/onCommit events on the form components. This will allow you to update the filter model programmatically.
  2. We move the data provider concept at the page level, just like queries/actions and let it hold the filter state. We add UI that lets you bind page state to filter model items. This essentially creates global filter model state and is very similar to how queries/actions already work. I'm slightly more inclined towards this solution. I'll try to write up a feature request for this idea this week.

Lifting/binding the filterModel state to the page level certainly seems a better way to solve the problem since it will allow other UI elements to manipulate its value and effectively implement filters outside the grid. Something like this one but built using the toolpad UI.

This could hold true for other controlled models like sortModel for example which the users may want to access using some custom UIs.

@prakhargupta1 prakhargupta1 added the scope: toolpad-studio Abbreviated to "studio" label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request scope: toolpad-studio Abbreviated to "studio"
Projects
None yet
Development

No branches or pull requests

4 participants