igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

igx-grid - Need to improve the experience when user updates cell values on sorted column.

Open gdayori opened this issue 8 years ago • 15 comments

Description

When I update a cell on a sorted column, then the updated record immediately goes out of the grid view because sorting feature runs every cell update. Basically I think this is right behavior since it's sorted, but inconvenient for users in some way. For example you want past some cells from Excel to the grid and one of the columns is sorted, just after you pasted the cells on the grid you would lost the pasted cells because they are immediately gone. User can't understand what's happened in this scenario.

Can you consider to have an option that developer can turn off the auto sorting when the value got updated?

Steps to reproduce

Copy & Past scenario

  1. Open https://stackblitz.com/edit/igx-grid-editing-while-sorting
  2. Sort Name column
  3. Open Excel and prepare data below, and copy them. aaa | bbb yyy | zzz
  4. On the stackblitz sample, select a cell on the sorted Name column, and past ctrl + C

Result

You would lost pasted cell, maybe yyy | zzz, because it's gone to the last of records.

Expected result

Remaining updated cells and once user sort columns then they gets sorted.

Attachments

https://stackblitz.com/edit/igx-grid-editing-while-sorting

gdayori avatar Oct 05 '18 10:10 gdayori

Isn't there to workaround this via the upcoming feature for Grid Transactions? #566

StefanIvanov avatar Oct 08 '18 08:10 StefanIvanov

@Lipata can you check the issue and answer Stefan

SlavUI avatar Oct 11 '18 07:10 SlavUI

Transaction provider in the grid is not related to the sorting. The provider only save changes in a pending collection and later updates them at once to the grid's data source.

It's all about Sorting Pipe and the way grid handles changes. When the cell values are updated then the grid triggers change update and going through the sorting pipe the rows are sorted, according to new values. So the only way to prevent this, with the current implementation, is to disable sorting.

Lipata avatar Oct 11 '18 09:10 Lipata

The behavior affects the situation when a column is sorted or filtered. My initial investigation shows that we can achieve the desired behavior by introducing a new pipe trigger only for the sorting and filtering pipes and a new input to control the behavior.

@SlavUI , @rkaraivanov , @zdrawku shall we implement this ?

I was not able to come up with a work around.

hanastasov avatar Nov 01 '18 10:11 hanastasov

@hanastasov I think this is a good addition to the Grid for users. We should add it to the Backlog and implement it :)

SlavUI avatar Nov 01 '18 11:11 SlavUI

@rkaraivanov had some concerns about the idea to have additinal pipe. Once we clear this out we can think of any implementation or not

zdrawku avatar Nov 07 '18 12:11 zdrawku

The angular lifecycle is such that updates to the data trigger view updates, which means that all operations are immediately reapplied to the data. In order to accommodate for the data to go through partial transformations, depending on certain user interactions, would break the general data flow model and would lead to a number of inconsistencies and inevitably bugs. I'm marking this as by design.

If I developer wants, they can reset the sorting programmatically before certain interactions are performed, which means that they would take over the data flow model by removing certain pipe triggers in scenarios like editing, pasting data, if they want. Anyways the data paste is a developer controlled action, and they have available API for sorting reset.

kdinev avatar Nov 13 '18 09:11 kdinev

There’s no workaround so far. If the filtering / sorting gets programmatically reset before cell editing, then the user would lose the record to update before editing. What customers wants to do is editing/pasting cells after sorting/filtering.

gdayori avatar Nov 14 '18 08:11 gdayori

@gdayori The only way for us to stop the pipe triggers on user interaction, is to have flags on the pipes, which explicitly tell them to do nothing. Applying the flag, however, would mean that the pipes would stop executing for the time being, meaning that the developer would have to hook on all other interactions, which need the pipes to trigger, and would have to flip the flag back off, in order to have an actual pipe transform happening.

Example (in pseudo-code):

onPaste => grid.stopPipeTriggers = true;
// then all this should also be happening
onGridHeaderClick => grid.stopPipeTriggers = false;
onGridSorting => grid.stopPipeTriggers = false;
onGridFiltering => grid.stopPipeTriggers = false;
onGridGrouping => grid.stopPipeTriggers = false;
onGridColumnMoved => grid.stopPipeTriggers = false;
...
etc. etc. etc.

Unlike jQuery, for example, in Angular this is the general data flow, as I already pointed out above, and breaking it would have reflection on all grid interactions.

kdinev avatar Dec 03 '18 13:12 kdinev

@kdinev Thank you for the update! Does those APIs solve the issue here? Please check the Step to reproduce and Expected result. In this case with the APIs you mentioned, I need to stop pipe trigger like setting grid.stopPipeTriggers = false; between step2 and step3. But I'm concerned that when user paste data then the Name column gets unsorted. What the users want is Remaining updated cells on the same position and and once user sort columns then they gets sorted.

gdayori avatar Dec 06 '18 01:12 gdayori

@gdayori This is not an existing property. I'm displaying what would be the result of introducing a "stopTrigger", that the developer would manually have to enable it back, and it wouldn't be deterministic when and how they should do that, as it would have to be at a lot of places.

kdinev avatar Dec 06 '18 08:12 kdinev

@kdinev I understand the code was just your example. The goal is to make the expected result achievable, to remain records when the cells are updated and once user sorts columns by clicking headers then they get sorted . How to achieve it is up to the team but I just wanted to make sure the goal will be achieved.

gdayori avatar Dec 07 '18 02:12 gdayori

@gdayori What I'm trying to explain is that this pipe doesn't simply trigger on header click. Even scrolling triggers it, as the data that needs to be brought into view needs to get sorted, in order for the view to get sorted results. The impact of such a change is enormous, which is why I'm telling you that we shouldn't be making it.

kdinev avatar Dec 07 '18 08:12 kdinev

@kdinev Now I understand how it's complicated and hard to manage the triggers. I agree with that we shouldn't be making it. @tkiryu Do you have any idea to achieve it in another way?

gdayori avatar Dec 12 '18 02:12 gdayori

@gdayori closing this one.

SlavUI avatar Jan 08 '19 08:01 SlavUI