FlexGrid with Dropdowns - Pasting multiple rows uses last row value only

Posted by: willingc on 26 April 2020, 12:46 am EST

  • Posted 26 April 2020, 12:46 am EST

    Hello, thank you in advance for your time on this issue.

    My app is angular 8. I am using flex grid with dataMaps for my dropdown columns. If my columns and values are:

    Col1_Dropdown, Col2_Text

    {ID: 1, Name: “G1”}, “Test1”

    {ID: 2, “G2”}, “Test2”

    {ID: 3, “G3”}, “Test3”

    And I copy all 3 rows and paste them I get the following:

    Col1_Dropdown, Col2_Text

    {ID: 1, Name: “G1”}, “Test1”

    {ID: 2, “G2”}, “Test2”

    {ID: 3, “G3”}, “Test3”

    {ID: 3, “G3”}, “Test1”

    {ID: 3, “G3”}, “Test2”

    {ID: 3, “G3”}, “Test3”

    The dropdown column has the last row values replicated three times, but the text column is replicated like I want/expect.

    This stackblitz shows the issue: https://stackblitz.com/edit/angular-o4mwk3?file=src%2Fapp%2Fapp.component.ts

    How do I get flex grid dropdowns to work how I am expecting?

    Thanks

    -Chris

  • Posted 27 April 2020, 6:00 am EST

    Hi,

    The issue occurring because you have bound the FlexGrid to a very complex object. While copying the data, only the data displayed on the grid is copied and same goes while pasting.

    When you pasted the data, the data does not contain information about the Bioreactors object, it only contained what is displayed on the grid, like G1, 1. And, when this data is pasted on the grid, the dataMap does not have any ‘G1, 1’ data actually present, so it is not able to update the value properly and shows ‘G1, 3’ for all of the cells because the newItemCreator returns an object with ‘G1, 3’ as the first and last Bioreactor.

    To resolve this issue, I would suggest you first create a DataMap by creating a copy of the Bioreactor items so that it will not be bound with the actual Bioreactor in the grid. Then, you can handle the pastedCell event of the FlexGrid and get the Bioreactor item using the pasted data and manually set the grid’s data using this item.

    Please refer to the sample link below:

    https://stackblitz.com/edit/angular-qqxyqp

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels