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

Allow delete but not edit or add

5 Answers 716 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ruth Goldberg
Top achievements
Rank 1
Ruth Goldberg asked on 11 Feb 2010, 09:24 PM
I want to allow the user to delete a row but enter data for add and edit in a separate window. I set Allow delete row to true and Allow Edit and Allow Add to false. If I am in the grid and press the delete key, nothing happens and the row changing event is not called. If I right click, I see no option to delete the row. However, I can delete the row programatically via a toolstrip button. Does disabling edit automatically disable delete, even if I've specified otherwise?

5 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 12 Feb 2010, 08:42 AM
Hi Ruth Goldberg,

This options are independent. This means that if you disable editing of a row, you can still add or delete a row. I couldn't reproduce the issue with the supplied information. I tried to achieve it with the following code snippet:

private void Form_Load(object sender, EventArgs e)
{
    this.radGridView.DataSource = yourDataSource;
    this.radGridView.MasterGridViewTemplate.AllowDeleteRow = true;
    this.radGridView.MasterGridViewTemplate.AllowEditRow = false;
    this.radGridView.MasterGridViewTemplate.AllowAddNewRow = false;
}

Could you please provide a sample project or a code snippet which reproduces the issue?

Regards,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ruth Goldberg
Top achievements
Rank 1
answered on 15 Feb 2010, 09:25 PM
I was using the designer to set these properties. I didn't do it in code. I can see the lines to set allowedit row and allowaddnewrow being set in the generated code. I didn't see the line for allowdeleterow, so I put it in my load event. It didn't make a difference. Here is the code for my load function. The translateform function translates labels to foreign languages, if applicable, but the countries were equal in my test, so it wasn't called.

 

Private Sub UserMaint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' icon visible until data is loaded

 

Me.ProgressIcon.Visibility = ElementVisibility.Visible

 

' translate form

 

If My.Application.ag.Country <> My.Application.ag.SYSDefaultCountry Then

 

My.Application.ag.TranslateForm(Me)

 

End If

 

' update status bar text

 

Me.StatusText.Text = My.Application.ag.AGTranslate(41, "Loading Data ...")

 

' get table data

 

Me.TblUsersTableAdapter.Fill(Me.DataSet1.tblUsers)

 

' expressions for calculated columns

 

Me.TblUsersRadGridView.Columns("Multi-Country").Expression = "USR_Multi_Country_Flag = 'Y'"

 

Me.TblUsersRadGridView.Columns("Status").Expression = "IIF(USR_Status='A','Active','Inactive')"

Me
.TblUsersRadGridView.MasterGridViewTemplate.AllowDeleteRow = True

 

' fit column sizes to data

 

Me.TblUsersRadGridView.MasterGridViewTemplate.BestFitColumns()

 

' save grid layout to a temp file, so we can refresh

 

 

 

 

Try
Me.TblUsersRadGridView.SaveLayout(My.Computer.FileSystem.SpecialDirectories.Temp & "\UserMaintGrid")

 

Catch ex As Exception

 

'if it doesn't work because of a firewall, just forget it

 

End Try

 

' icon visible until data is loaded

 

Me.ProgressIcon.Visibility = ElementVisibility.Hidden

 

Me.StatusText.Text = ""

 

End Sub

 

 

 

 

0
Martin Vasilev
Telerik team
answered on 18 Feb 2010, 07:26 AM
Hello Ruth Goldberg,

Thank you for the provided code. I have examined it but I cannot find anything that could be the reason that delete is not working on your side. Please, try setting all three properties using code in form Load event as Svett has already shown. If this does not help, please open a new support ticket and send me a small working example that demonstrates the issue. This will help me to investigate your custom scenario further and provide accurate assistance.

Best wishes,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ruth Goldberg
Top achievements
Rank 1
answered on 25 Feb 2010, 01:40 PM
I found the problem. The smart tag for Radgridview has 3 checkboxes on the bottom: Enable adding, enable editing and enable column reordering. If enable editing is unchecked, delete won't work even if allow delete is true. When I checked it, everything worked. I have no idea what property that check box relates to because it doesn't turn off allow delete (It's on when I debug and look at the value).
0
Martin Vasilev
Telerik team
answered on 01 Mar 2010, 07:38 AM
Hello Ruth Goldberg,

Thank you for getting back to me. If the EnableEdit option (in the PropertyBuilder) is unchecked that puts the whole RadGridView in ReadOnly mode and deleting rows is not allowed. ReadOnly mode overrides AllowDeleteRow property, and that is why you cannot delete a row even if it is set to true.

Let me know if you have any additional questions. 

Sincerely yours,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Ruth Goldberg
Top achievements
Rank 1
Answers by
Svett
Telerik team
Ruth Goldberg
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or