This is a migrated thread and some comments may be shown as answers.

Copying multiple new rows from excel and paste the same as new rows onto the WPF radgrid.

2 Answers 199 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mausami
Top achievements
Rank 1
Mausami asked on 04 Jul 2011, 04:59 PM
Hello Telerik team,

First of all I would like to thank and congratulate your team for providing guidance with demos wherever required for almost all the queries that we raise.

I am aware that currently the WPF telerik grid allows creating a new row on a button click.

But I would like to know if it is possible to paste multiple new rows onto the WPF telerik rad grid that are being copied from an excel.

Also, is it possible to add a context menu to the row indicator column.



Thanks,
Regards,
Mausami

2 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 11 Jul 2011, 08:40 AM
Hello Mausami,

The grid is capable of inserting new rows into the grid upon pasting. This has some limitation since you have to be at the last item of the grid. For example, you could try the following: Insert new row by pressing the Insert key. Then select this new row and paste the data.



Let me know if that will work for your case. I have attached a short video illustrating this approach. 

  Regarding placing ContextMenu on the row indicator, you could try the following:

public MainWindow()
{
    InitializeComponent();
  
    this.playersGrid.RowLoaded += new EventHandler<RowLoadedEventArgs>(playersGrid_RowLoaded);
}
  
void playersGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
    var row = e.Row as GridViewRow;
  
    if (row != null)
    {
        var indicator = row.ChildrenOfType<Border>().Where(b => b.Name == "PART_IndicatorPresenter").FirstOrDefault();
  
        var menu = new ContextMenu();
        menu.Items.Add(new MenuItem { Header = "h1" });
        menu.Items.Add(new MenuItem { Header = "h2" });
  
        indicator.ContextMenu = menu;
    }
}
   

Regards,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

paste multiple new rows
0
Mausami
Top achievements
Rank 1
answered on 11 Jul 2011, 09:01 AM
Hello Milan,

Thank-you very much for your reply.

I tried the code snippet for adding a content menu to the row indicator.
But I get an error at the below given line of code.


var indicator = row.ChildrenOfType<Border>().Where(b => b.Name == "PART_IndicatorPresenter").FirstOrDefault(); 
            
  
Error : 'Telerik.Windows.Controls.GridView.GridViewRow' does not contain a definition for 'ChildrenOfType'
         and no extension method 'ChildrenOfType' accepting a first argument of type 
        'Telerik.Windows.Controls.GridView.GridViewRow' could be found
         are you missing a using directive or an assembly reference?)

Grateful if you could assist.



Regards,
Mausami
Tags
GridView
Asked by
Mausami
Top achievements
Rank 1
Answers by
Milan
Telerik team
Mausami
Top achievements
Rank 1
Share this question
or