Unable to highlight pasted RadGridView cells, if virtualization is enabled.

2 Answers 21 Views
GridView
Meera
Top achievements
Rank 1
Iron
Meera asked on 26 Feb 2024, 10:52 AM

Hello,

I am new to Telerik, in my application we are using RadGridView and load the data dynamically.

when data is large, and I copy pasted from excel then my cells are not highlighted. data is pasted correctly but highlighted cell is not working.

If I edit it manually then it's working fine and I handled this highlighted cell in "CellEditEnd" event.

I walk through multiple forums but none of them are working for me.

I tried to raise ClipboardPaste event but that is not available my RadGridView control.

Also I manually created below function but "MyRadGrid.ChildrenOfType<GridViewRow>()" is not giving me all the index of my radgridview it gives 10 or 15 according to the screen size because of virtualization

private void HighlightUpdateCell(int rowIndex, int columnIndex)
        {           
            int rowNumber = 0;
            foreach (GridViewRow gr in MyRadGrid.ChildrenOfType<GridViewRow>())
            {
                if (rowNumber == rowIndex)
                {
                    gr.Cells[columnIndex].Background = Brushes.Yellow;
                    break;
                }
                rowNumber++;
            }
        }

Another approach was to create a property and set it in style but that is also not working. as cells are not showing in edited mode after pasting data.

I also tried using CellStyleSelector but the is applying changes only on load after that this method is not call itself.

 

I tried for ClipboardPaste event but unable to find that in my application.

I am using latest Telerik libraries from 2024

 

Can you please help to highlight the cells of RadGridView after paste is completed.

 

 

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 27 Feb 2024, 02:47 PM

Hello Meera,

When the UI virtualization is enabled you need to use the RowStyle and CellStyle to modify the row and column visuals. Otherwise, you get issues as the reported ones, which happens because the same containers get re-used for different rows and columns. Basically, you can use the corresponding style selectors or data bindings in the styles. I have attached a small sample that shows one way to achieve your requirement using the CellStyleSelector of the columns. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Meera
Top achievements
Rank 1
Iron
commented on 29 Feb 2024, 07:30 AM

Hello Martin,

Thank you for your solution but unfortunately it did not work for me.

As I already mentioned that I tried CellStyleSelector but it was highlighting entire Row or Column for RadGridView.

I want to highlight selected cell only like below. it can be one cell or all depending upon user. just to know that data get pasted.

 

Martin Ivanov
Telerik team
commented on 04 Mar 2024, 08:08 AM

I've double checked my project, but the style is applied only to the pasted cells, not the entire row. You can also try to set the SelectionUnit property of RadGridView to Cell and see if this makes the things better on your side.
0
Meera
Top achievements
Rank 1
Iron
answered on 12 Apr 2024, 08:29 AM

Thank you for the support.

I modified little bit of your code as per my application and now working as expected.

Tags
GridView
Asked by
Meera
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Meera
Top achievements
Rank 1
Iron
Share this question
or