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

[Solved] Hierarchical grid editing with GridDropDownColumn problem

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob Heckart
Top achievements
Rank 1
Rob Heckart asked on 15 May 2008, 05:58 PM

I have a 3-tier hierarchical grid that looks like this:

Areas
    Attributes
        Details

In the Attributes detail table, there are three columns: Description, Grade and Comments. I am performing in-place editing and have chosen to use a GridDropDownColumn tied to a LinqDataSource to bring back a simple english-value pair list that fills the Grade column. This is causing a problem on the client that apparently stops the RadAjaxManager from working. If I take the dropdown out and put a regular bound control back in, all is well. Other custom columns seem to work ok.

Another problem I've run into is that the Description field is supposed to be a read-only field and is marked as such. There are times when hitting Update or Cancel that the grid forgets it's a read-only field and presents a textbox instead.

A third problem I'm having is that when I perform an action that fills the grid I run the following code to turn on edit mode by default in the Attributes detail table:

Protected Sub grdRatingDetail_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdRatingDetail.PreRender  
 
     For Each nestedViewItem As GridNestedViewItem In grdRatingDetail.MasterTableView.GetItems(GridItemType.NestedView)  
         For Each newnest As GridTableView In nestedViewItem.NestedTableViews  
             For Each row As GridDataItem In newnest.Items  
                 row.Edit = True 
             Next  
         Next  
     Next  
 
End Sub 

This code works great every time except the first time the grid is shown - in that case, all the rows' backgrounds are yellow indicating they're in edit mode, but no controls show and the Edit column still shows "Edit" instead of "Update/Cancel."

Rob

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 May 2008, 06:26 AM
Hi,

How are you binding the Grid? Try using AdvanceDataBinding technique.
Advanced data-binding

Shinu.
0
Rob Heckart
Top achievements
Rank 1
answered on 16 May 2008, 12:10 PM
That's the technique I am using - the NeedDataSource for the MasterTableView was this code:

        Protected Sub grdRatingDetail_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdRatingDetail.NeedDataSource  
 
            If Not e.IsFromDetailTable Then 
 
                gridEditMode = False 
 
                Dim competencyAreas = From ca In db.AreaLevels _  
                                      Where ca.EmployeeAssessmentID = _  
                                      If(tabAssessedLevels.SelectedTab Is Nothing, -1, CInt(tabAssessedLevels.SelectedTab.Value)) _  
                                      Select ca.CompetencyArea.CompetencyName, ca.AssessmentAreaLevelID  
 
                grdRatingDetail.MasterTableView.DataSource = competencyAreas  
 
            End If 
 
        End Sub 

And the code to fill the DetailTableViews is:

        Protected Sub grdRatingDetail_DetailTableDataBind(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles grdRatingDetail.DetailTableDataBind  
 
            Dim dataItem = CType(e.DetailTableView.ParentItem, GridDataItem)  
 
            Select Case e.DetailTableView.Name  
 
                Case "AttributeLevel" 
 
                    gridEditMode = True 
 
                    Dim areaLevel = dataItem.GetDataKeyValue("AssessmentAreaLevelID").ToString  
 
                    Dim attributes = From attr In db.AttributeLevels _  
                                     Group Join com In db.Comments On attr Equals com.AttributeLevelComments Into comments = Group _  
                                     From com In comments.DefaultIfEmpty _  
                                     Select New With {attr.AssessmentAttributeLevelID, .Attribute = attr.CompetencyAttribute.AttributeName, attr.AssessmentAreaLevelID, .Assessment = attr.GradeID, .Comment = com.Comment}  
 
                    e.DetailTableView.DataSource = attributes  
 
                Case "AttributeDetail" 
 
                    gridEditMode = False 
 
                    Dim attributeLevel = dataItem.GetDataKeyValue("AssessmentAttributeLevelID").ToString  
 
                    Dim details = From detail In db.AttributeDetails _  
                                  Group Join com In db.Comments On detail Equals com.AttributeDetail Into comments = Group _  
                                  From com In comments.DefaultIfEmpty _  
                                  Select New With {detail.AssessmentAttributeDetailID, _  
                                                   detail.AssessmentAttributeLevelID, _  
                                                   detail.AssessmentDate, _  
                                                   detail.AssignmentID, _  
                                                   .Comment = com.Comment, _  
                                                   detail.MentorMenteeID, _  
                                                   detail.TargetTypeID, _  
                                                   detail.TrainingResourceID}  
 
                    e.DetailTableView.DataSource = details  
 
            End Select 
 
        End Sub 
0
Princy
Top achievements
Rank 2
answered on 16 May 2008, 12:39 PM
Hi Rob,

Try Rebinding the Grid after setting it in edit mode.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridDataItem item in RadGrid1.Items)  
        {  
            item.Edit = true;  
        }  
        RadGrid1.Rebind();  
 
    } 


Princy.
Tags
Grid
Asked by
Rob Heckart
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rob Heckart
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or