Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
703
How do I disable existing rows
posted

I am stucked at the situation where I need to disable few columns of a each except newly added row.

That is I have 10 columns in grid and I want first three columns that are binded from the rows coming from db as disabled or read-only rest editable. if I add new row then all columns of new row must be enabled until and unless it is saved.

 

I dont have any DataKey or Primary key for my row. I have to check for some thing like IsNewRow. 

in my current scenario i am using this code block

    Private Sub dgTimeSheet_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles dgTimeSheet.InitializeRow

        ''if either column key is Project, Class or Milestone

        '' Activation.NoEdit = Disable and Activation.AllowEdit = Enable

        Dim index As Integer = e.Row.Index

 

        If e.Row.IsAddRow Then

            dgTimeSheet.Rows(index).Cells(PROJECT).Activation = Activation.AllowEdit

            dgTimeSheet.Rows(index).Cells(SERVICE_ISSUE_CLASS).Activation = Activation.AllowEdit

            dgTimeSheet.Rows(index).Cells(MILESTONE).Activation = Activation.AllowEdit

 

 

        Else

 

            dgTimeSheet.Rows(index).Cells(PROJECT).Activation = Activation.NoEdit

            dgTimeSheet.Rows(index).Cells(SERVICE_ISSUE_CLASS).Activation = Activation.NoEdit

            dgTimeSheet.Rows(index).Cells(MILESTONE).Activation = Activation.NoEdit

 

        End If

        CheckRows()

    End Sub

 

but the problem is that if i click on disabled rows then new rows also gets disabled., which i dont want

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Once you click away from the AddNew row, it's no longer an AddNew row. It gets commited to the data source and becomes a regular row. So perhaps what you need to do is mark the new rows in some way. You could use a hidden column with a boolean value in it and initialize the value of this column to false for all of the existing rows and then use the AfterRowInsert event to initialize the value of new rows to true. Then you could use this flag in InitializeRow rather than check IsAddRow.

Children
No Data