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

CheckBox in Hierarchy Mode

2 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Viktor
Top achievements
Rank 1
Viktor asked on 04 Mar 2014, 04:51 AM
I use manually generating hierarchy mode as it is described in http://www.telerik.com/help/winforms/gridview-hierarchical-grid-object-relational-hierarchy-mode.html
For bool fields I use GridViewCheckBoxColumn.
When I change bounded bool field in child object, the changes in CheckBoxEditor are not displayed (and vice versa, when I click a CheckBoxEditor, the changes are not reflected in object).
If I press a header for reorder, then the changes are partially displayed, but couple of checkbox are not change.

In debugger I see (rgvMain is RadGridView):

rgvMain.CurrentRow.ChildRows[1]:

    {Telerik.WinControls.UI.GridViewHierarchyRowInfo}
    [Telerik.WinControls.UI.GridViewHierarchyRowInfo]: {Telerik.WinControls.UI.GridViewHierarchyRowInfo}
    AllowedStates: Current | Selected
    AllowResize: true
    Cache: {Telerik.WinControls.UI.GridViewRowInfoCache}
    CanBeCurrent: true
    CanBeExpanded: false
    CanBeSelected: true
    Cells: {Telerik.WinControls.UI.GridViewCellInfoCollection}
    ChildRows: {Telerik.WinControls.UI.GridViewChildRowCollection}
    DataBoundItem: {UsonInfrastructure.Infrastructure.UserData.AccessProjection}
    dataBoundItem: {UsonInfrastructure.Infrastructure.UserData.AccessProjection}
    ErrorText: ""
    Group: null
    HasChildViews: false
    Height: 18
    HierarchyLevel: 1
    Index: 0
    IsAttached: true
    IsCurrent: false
    IsEditable: true
    IsExpanded: false
    IsInitialized: false
    IsModified: false
    IsOdd: false
    IsPinned: false
    IsSelected: false
    IsSystem: false
    IsValid: true
    IsVisible: true
    MaxHeight: -1
    MinHeight: 5
    parent: {Telerik.WinControls.UI.GridViewHierarchyRowInfo}
    Parent: {Telerik.WinControls.UI.GridViewHierarchyRowInfo}
    ParentRow: null
    PinPosition: None
    PropertyChanged: {Method = {Void RowInfo_PropertyChanged(System.Object, System.ComponentModel.PropertyChangedEventArgs)}}
    PropertyChanging: null
    RowElementType: {Name = "GridDataRowElement" FullName = "Telerik.WinControls.UI.GridDataRowElement"}
    rowState: {Telerik.WinControls.UI.GridViewRowInfo.GridViewRowInfoState}
    state: {BitVector32{00000000000000000000000001100001}}
    Tag: null
    Telerik.WinControls.Data.IDataItem.DataBoundItem: {UsonInfrastructure.Infrastructure.UserData.AccessProjection}
    Telerik.WinControls.Data.IDataItem.FieldCount: 3
    ViewInfo: {Telerik.WinControls.UI.GridViewInfo}
    viewInfo: {Telerik.WinControls.UI.GridViewInfo}
    ViewTemplate: {Telerik.WinControls.UI.GridViewTemplate}


rgvMain.CurrentRow.ChildRows[1].Cells[1].ColumnInfo

    {Reading (GridViewCheckBoxColumn)}
    [Telerik.WinControls.UI.GridViewCheckBoxColumn]: {Reading (GridViewCheckBoxColumn)}
    base {Telerik.WinControls.RadObject}: {Reading (GridViewCheckBoxColumn)}
    Accessor: {Telerik.WinControls.UI.VirtualHierarchyAccessor}
    accessor: {Telerik.WinControls.UI.VirtualHierarchyAccessor}
    AllowGroup: true
    AllowHide: true
    AllowReorder: true
    AllowResize: true
    AllowSort: true
    AutoEllipsis: true
    AutoSizeMode: DisplayedCells
    CanBeCurrent: true
    CanGroup: true
    CanSort: true
    CanStretch: false
    ConditionalFormattingObjectList: Count = 0
    conditionalFormattingObjects: Count = 0
    CustomDataOperation: None
    DisableHTMLRendering: true
    EnableExpressionEditor: false
    EventDispatcher: {Telerik.WinControls.UI.EventDispatcher}
    Expression: ""
    FieldAlias: ""
    FieldName: "ReadAccess"
    HeaderImage: null
    HeaderText: "Reading"
    HeaderTextAlignment: MiddleCenter
    ImageLayout: None
    Index: 1
    IsAutoGenerated: false
    IsCurrent: true
    IsDataBound: false        !!!!! may be this is a cause?
    IsFieldNamePath: false
    isFieldNamePath: false
    IsGrouped: false
    IsPinned: false
    IsSorted: false
    IsVisible: true
    MaxWidth: 60
    MinWidth: 60
    Name: "ReadAccesseffcd8a0-48d6-4e0d-9cda-4ba02cb0b53f"
    ownerTemplate: {Telerik.WinControls.UI.GridViewTemplate}
    OwnerTemplate: {Telerik.WinControls.UI.GridViewTemplate}
    PinPosition: None
    PropertyChanging: null
    ReadOnly: false
    RowSpan: 20
    sortOrder: None
    SortOrder: None
    StretchVertically: true
    Tag: null
    TextAlignment: MiddleLeft
    TextImageRelation: Overlay
    UniqueName: "ReadAccesseffcd8a0-48d6-4e0d-9cda-4ba02cb0b53f"
    VisibleInColumnChooser: true
    Width: 60
    WrapText: false

2 Answers, 1 is accepted

Sort by
0
Viktor
Top achievements
Rank 1
answered on 04 Mar 2014, 11:03 AM
UPD:

It helps:

 foreach (var template in rgvMain.CurrentRow.ViewTemplate.Templates)
                    {
                        template.Refresh();
                        template.Refresh(); // First time not work
                    }
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Mar 2014, 03:12 PM
Hello Viktor,

Thank you for contacting Telerik Support.

When you use RadGridView bound to custom objects, it is necessary to notify the RadGridView for any further changes related to the DataBoundItems. It is necessary to refresh the corresponding template, to which the current row is belonging to, together with refreshing the MasterTemplate:
private void radButton1_Click(object sender, EventArgs e)
{
  Product  row = this.radGridView1.CurrentRow.DataBoundItem as Product;
  if (row!=null)
  {
      row.Discontinued = !row.Discontinued;
      this.radGridView1.CurrentRow.ViewTemplate.Refresh();
      this.radGridView1.MasterTemplate.Refresh();
  }
}

You can refer to our Binding to Hierarchical Data Programmatically help article, where the the changes are automatically refreshed. Our Reflecting Custom Object Changes in RGV help article is quite useful as well about reflecting changes to RadGridView.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
GridView
Asked by
Viktor
Top achievements
Rank 1
Answers by
Viktor
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or