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

Check duplicate cells across pages

2 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saggiatorius
Top achievements
Rank 1
saggiatorius asked on 23 Apr 2010, 11:36 AM
Hello,

I need to check if a cell that the user is editing (cell in edit mode) does not exist in the rest of the radgrid (for the same column).
Since radgrid1.Items retrieves just the items of the current page, I tried to disable paging and filtering for a while in the validation method raised by the OnServerValidate event.
That's ok, but rebinding creates some problems for me.
Take as example that the user inserts a value duplicated.
The OnServerValidate event occurs twice in sequence (I don't know why) and the second time it is raised the cell changed by the user has the original text before editing (in fact we did a rebind!) and my validation method evaluates that everything is ok and generates no error message and no change in the DB. The expected behaviour was that the user receives a message error: "Duplicate value".

Could you help me?
Is there a way to disable paging and filtering without rebinding the grid, but just refreshing the interface?

Following is the code.

Thanks in advance.

    Public Sub ValidateDescriptionDuplicates(ByVal source As ObjectByVal args As ServerValidateEventArgs)  
        Dim desc As String 
        Dim id As String 
 
        Dim tb As New TextBox()  
        Dim hi As New System.Web.UI.HtmlControls.HtmlInputHidden()  
        Dim dvt As DataView  
        Dim dvr As DataRowView  
        Dim err As Integer 
        Dim e As DataGridItem  
        Dim dgi As GridDataItem  
 
        If Page.IsValid Then 
            dgi = Me.RadGrid1.EditItems(0)  
 
            Dim t As New Translate()  
 
            desc = MyRadUtility.GetControlValue(dgi, "textbox")  
            id = MyRadUtility.GetGridValue(dgi, "ID")  
            err = 0  
              
            RadGrid1.AllowPaging = False 
            Dim filterExp As String = RadGrid1.MasterTableView.FilterExpression  
            RadGrid1.AllowFilteringByColumn = False 
            RadGrid1.Rebind()  
 
            For Each dgiTemp As GridDataItem In RadGrid1.Items  
                If desc = GetControlValue  
dgiTemp, "label"And Not dgiTemp.GetDataKeyValue("ID") = id Then 
                    If Not Me.Customvalidator2 Is Nothing Then 
                        Me.Customvalidator2.Text = t.TranslateString("Attention! Description already inserted!")  
                    End If 
                    err = err + 1  
                End If 
            Next 
 
            RadGrid1.AllowPaging = True 
            RadGrid1.AllowFilteringByColumn = True 
            RadGrid1.MasterTableView.FilterExpression = filterExp  
            RadGrid1.Rebind()  
              
            If err = 0 Then 
                args.IsValid = True 
            Else 
                args.IsValid = False 
            End If 
        Else 
            args.IsValid = True 
        End If 
    End Sub 

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 Apr 2010, 06:25 AM
Hello saggiatorius,

Our system indicates, that you have opened a support ticket on the same matter.
To avoid duplicate posts, please refer to the ticket - we can continue our communication there.

Best wishes,
Yavor
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
saggiatorius
Top achievements
Rank 1
answered on 03 May 2010, 08:50 AM

I resolved this issue by two ways:
1. I called a SQL stored procedure to check if there are duplicate items in the DB
2. I saved in a session variable the datatableview with the data from the DB, and I iterate that when I need to check if there are duplicate items.

Disabling paging is not a good solution because check for duplicate items is executed inside the event method (onServerValidate) that is automatically called twice:
- the first time it really checks if the item that has been modified has duplicates
- the second time it does not check efficiently for duplicates because the datagrid was rebound the first time and the text modified by the user has been lost.

Tags
Grid
Asked by
saggiatorius
Top achievements
Rank 1
Answers by
Yavor
Telerik team
saggiatorius
Top achievements
Rank 1
Share this question
or