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

Insert New Row - Nothing Happens

2 Answers 326 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ledcor Development Team
Top achievements
Rank 1
Ledcor Development Team asked on 03 Jun 2013, 01:24 AM
I have a GridView in a WPF page. I've got the "Click here to add new item" row to appear in the grid, but when I click anywhere in the row, nothing happens. I cannot get the new row to appear. I've got "ShowInsertRow" and "CanUserInsertRow" both set to True. Am I missing something? Is there something else I have to do to make the new line appear?

Here's my XAML for the control, Thanks for your help.:

<telerik:RadGridView Name="rgvParameters" Grid.Column="1" HorizontalAlignment="Left" Margin="134,476,0,0" VerticalAlignment="Top" Height="171" Width="496" ItemsSource="{Binding}" IsFilteringAllowed="False" ShowGroupPanel="False" AutoGenerateColumns="False" SelectionUnit="Cell" ShowInsertRow="True" ActionOnLostFocus="None" CanUserInsertRows="True" CanUserReorderColumns="False" CanUserSortGroups="False" CanUserDeleteRows="False" SelectionChanged="rgvParameters_SelectionChanged">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn Name="rgcParameterID" DataMemberBinding="{Binding [ParameterID]}" Width="0" MaxWidth="0" MinWidth="0" />

                            <telerik:GridViewDataColumn Name="rgcApplicationID" DataMemberBinding="{Binding [ApplicationID]}" Width="0" MaxWidth="0" MinWidth="0" />
                            <telerik:GridViewDataColumn Name="rgcParameterName" DataMemberBinding="{Binding [ParameterName]}" 
                                Header="Key" />
                            <telerik:GridViewDataColumn Name="rgcParameterValue" DataMemberBinding="{Binding [ParameterValue]}"
                                Header="Value" />
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>


Edit: One thing I just noticed. If I bring up the page and immediately click the new row, the new row line does appear. If I populate the grid with current data from the database with this line of code, the insert new row command no longer works:

rgvParameters.ItemsSource = businessRules.GetParameters(dsApp.Tables[0].Rows[0]["ApplicationID"].ToString()); 

Why does setting the ItemSource value invalidate the user's abiity to add a new record to the grid?

2 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 05 Jun 2013, 02:01 PM
Hi Dave,

Generally, if you want to be able to add new items you need:
1. Default (parameterless) constructor for your business object.
2. Source collection that allows insertion/ deletion.

You can check this help article for a reference.

Regards,
Yoan
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Wilfred
Top achievements
Rank 1
answered on 12 Feb 2019, 01:41 PM
old thread but I found that when I sorted my list on ItemSource assignment, it prevented the new row from being added. Try to sort your collection prior to ItemSource assignment
Tags
GridView
Asked by
Ledcor Development Team
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Wilfred
Top achievements
Rank 1
Share this question
or