This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
Add meta data to ClrDatagridStateInterface to distinguish between user triggered actions and component responses #4471
Labels
@clr/angular
component: datagrid
flag: has workaround
resolution: enhancement request
Issues that are captured in our enhancement request list.
type: enhancement
Summary
ClrDgRefresh
emits theClrDatagridStateInterface
for two different reasons for which I propose a change to the interface, in order to be able to distinguish them.When the user clicks on sort, filter or any pagination elements, the resulting state change can be interpreted as an action, which needs a corresponding reaction (e.g. fetch new data)
When the user uses a separate component to filter data and the result of that request is displayed/binded to the datagrid, then the emitted state is mere a response.
A frequent use case I have is described in the use case section
I propose to add the originating DOM Event to the
ClrDatagridStateInterface
, which states that the change originates from a event by the user from within the datagridIt affects
@clr/angular
directlyIt should not impact any existing behaviors.
Use case
I have a server driven datagrid without the smart iterator. Hence the pagination data is binded manually. I also use a separate filter component. Changes of the filter and the datagrid
ClrDatagridStateInterface
is updated to the url as query strings which triggers the data fetch. The result is binded to the datagrid.The user navigates to page 2 via the pagination next button and we get a new
ClrDatagridStateInterface
. This user triggered change should update the url and trigger a data fetch.The user now changes the filter and expects to start on page 1 of the new results. When I bind the results of the request to the datagrid, it emits as expected a new
ClrDatagridStateInterface
. This time however, the state should NOT update the url, which would trigger a new request.Workarounds
Currently I'm using a custom directive to listen to the 'clrDgRefresh' event and emit its own 'refresh' event when it has detected a 'mousedown' event on one of the following elements
PS:
My team and I are heavily using clarity datagrids for IoT projects, so a big thanks to clarity for providing such an amazing framework!
PPS:
I personally would love to contribute and solve this issues if approved.
The text was updated successfully, but these errors were encountered: