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

[Solved] Hirarchy grid issue

15 Answers 189 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sulagna
Top achievements
Rank 1
sulagna asked on 08 Oct 2010, 03:55 PM
Hi,
I am following the sample example of hirarchical grid of Telerik Control but only getting till 1st level of hirarchy.
My hirarchy should be of 3 levels like Grid1->Grid2->Grid3.I am getting Grid1 but Grid2 and Grid 3 data I am not getting.

I am pasting the .xaml file and screen shot for your reference.

<

 

 

telerik:RadGridView x:Name="RadUseCaseGridView" CanUserFreezeColumns="False" GridLinesVisibility="Horizontal" ItemsSource="{Binding Summary.UseCaseList}"

 

 

 

 

RowLoaded="RadUseCaseGridView_RowLoaded"

 

 

 

 

 

IsReadOnly="True" AutoGenerateColumns="False">

 

 

 

 

 

<telerik:RadGridView.ChildTableDefinitions>

 

 

 

 

<telerik:GridViewTableDefinition>

 

 

 

 

<telerik:GridViewTableDefinition.Relation>

 

 

 

 

<telerik:PropertyRelation ParentPropertyName="Summary.UseCaseList" />

 

 

 

 

</telerik:GridViewTableDefinition.Relation>

 

 

 

 

</telerik:GridViewTableDefinition>

 

 

 

 

</telerik:RadGridView.ChildTableDefinitions>

 

 

 

 

 

<telerik:RadGridView.Columns >

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseNum}" Header="UseCase Number" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseName}" Header="UseCase Name" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseStatus}" Header="UseCase Status" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseDesc}" Header="UseCase Description" />

 

 

 

 

</telerik:RadGridView.Columns>

 

 

 

 

 

 

<telerik:RadGridView.HierarchyChildTemplate>

 

 

 

 

 

<DataTemplate>

 

 

 

 

<telerik:RadGridView x:Name="RadFeatureGridView" RowLoaded="RadFeatureGridView_RowLoaded" CanUserFreezeColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding Summary.FeatureList}" ShowGroupPanel="False" IsReadOnly="True">

 

 

 

 

<telerik:RadGridView.ChildTableDefinitions>

 

 

 

 

<telerik:GridViewTableDefinition>

 

 

 

 

<telerik:GridViewTableDefinition.Relation>

 

 

 

 

<telerik:PropertyRelation ParentPropertyName="Summary.FeatureList" />

 

 

 

 

</telerik:GridViewTableDefinition.Relation>

 

 

 

 

</telerik:GridViewTableDefinition>

 

 

 

 

</telerik:RadGridView.ChildTableDefinitions>

 

 

 

 

 

<telerik:RadGridView.Columns >

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureNumber}" Header="Feature Number" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureName}" Header="Feature Name"/>

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureStatusName}" Header="Feature Status" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureEstimate}" Header="Reference Estimate" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding ReviseEstimate}" Header="Revised Size Estimate"/>

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding PercentageCompleted}" Header="% Completed" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding FeaturePriority}" Header="Criticality" />

 

 

 

 

</telerik:RadGridView.Columns>

 

 

 

 

 

<telerik:RadGridView.HierarchyChildTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<telerik:RadGridView x:Name="RadTaskGridView" CanUserFreezeColumns="False" RowLoaded="RadTaskGridView_RowLoaded" AutoGenerateColumns="False" ItemsSource="{Binding Summary.TaskList}" ShowGroupPanel="False" IsReadOnly="True">

 

 

 

 

<telerik:RadGridView.Columns >

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding TaskNumber}" Header="Task #" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding TaskName}" Header="Task Name"/>

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding TaskStatus}" Header="Task Status" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding ResourceName}" Header="Owner"/>

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding ScheduledEffort}" Header="Scheduled Effort" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding ActualEffort}" Header="Actual Effort"/>

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding RemainingEffort}" Header="Remaining Effort" />

 

 

 

 

<telerik:GridViewDataColumn DataMemberBinding="{Binding IterationName}" Header="Iteration Name"/>

 

 

 

 

</telerik:RadGridView.Columns>

 

 

 

 

</telerik:RadGridView>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadGridView.HierarchyChildTemplate>

 

 

 

 

</telerik:RadGridView>

 

 

 

 

</DataTemplate>

 

 

 

 

 

</telerik:RadGridView.HierarchyChildTemplate>

 

 

 

 

 

</telerik:RadGridView>

code behind:

 

public DataContracts.Summary Translate(LeMonWeb.Summary summary)
        {
            DataContracts.Summary summaryObject = null;
            IList<DataContracts.Task> taskList = null;
            IList<DataContracts.Feature> featureList = null;
            IList<DataContracts.UseCase> useCaseList = null;
          
            if (summary != null)
            {
                summaryObject = new DataContracts.Summary();
                useCaseList = new List<DataContracts.UseCase>();
                taskList = new List<DataContracts.Task>();

                foreach (LeMonWeb.Summary.UseCaseRow usecaseRow in summary.Tables[0].Rows)
                {
                    featureList = new List<DataContracts.Feature>();
                    var useCaseObj = new DataContracts.UseCase
                    {
                        UseCaseNum = usecaseRow.UseCaseNumber,
                        UseCaseName = usecaseRow.UseCaseName,
                        UseCaseStatus = usecaseRow.UseCaseStatus,
                        UseCaseDesc = usecaseRow.UseCaseDesc,
                        UseCaseId = usecaseRow.UseCaseID,                       
                    };
                    useCaseList.Add(useCaseObj);
                }
                foreach (LeMonWeb.Summary.FeatureRow featureRow in summary.Tables[1].Rows)
                {
                    var featureObj = new DataContracts.Feature
                    {
                        UseCaseID = featureRow.UseCaseID,
                        FeatureName = featureRow.FeatureName,
                        PercentageCompleted = featureRow.PercentageCompleted,
                        FeatureNumber = featureRow.FeatureNumber,
                        FeatureEstimate = featureRow.FeatureEstimate,
                        Priority = featureRow.Priority,                       
                        FeatureStatusName = featureRow.FeatureStatus,                              
                    };
                    featureList.Add(featureObj);
                }
                foreach (LeMonWeb.Summary.TaskRow taskRow in summary.Tables[2].Rows)
                {
                    var taskObj = new DataContracts.Task
                    {
                        FeatureID = taskRow.FeatureID,
                        TaskDesc = taskRow.TaskDesc,
                        TaskNumber = taskRow.TaskNumber,
                        TaskStatus = taskRow.TaskStatus,
                        ActualEffort = taskRow.ActualEffort,
                        RemainingEffort = taskRow.RemainingEffort,
                        ResourceName = taskRow.ResourceName,
                        TaskName = taskRow.TaskName,
                        ScheduledEffort = taskRow.ScheduledEffort,
                    };

                    taskList.Add(taskObj);
                }
                summaryObject.UseCaseList = useCaseList;
                summaryObject.FeatureList = featureList;
                summaryObject.TaskList = taskList;  
            }
            return summaryObject;           

        }
Please help
Thanks,
Sulagna

15 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 11 Oct 2010, 09:14 AM
Hello sulagna,

There are a couple of options here and the best approach to choose depends on your exact requirements. You may take a look at our online documentation and this forum thread for a reference. 
In case none of those is appropriate for your scenario, I would need more details about your application so that I could provide you with a proper solution.

Greetings,
Maya
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
sulagna
Top achievements
Rank 1
answered on 11 Oct 2010, 12:22 PM
Hi,
I went through forum given but not able to resolve that.My requirement is everything should be in xaml file by property binding.I should not write any events in code behind.I tried the documentation link peovided but not able to resolve that.

Please help.
Sulagna 
0
Maya
Telerik team
answered on 11 Oct 2010, 02:37 PM
Hi sulagna,

I am sending you a sample project illustrating how to create a three-layer hierarchy. Feel free to change it so that it meets your requirements and send it back to me in order to demonstrate the problem you specified initially.

 
Sincerely yours,
Maya
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
sulagna
Top achievements
Rank 1
answered on 12 Oct 2010, 09:13 AM
Thank you so much Maya for sending me three levels of hirarchy.
But problem that I am facing currently is I have a data Contract currently with has 3 lists like this.which has 3 lists inside which becomes 3 observable collection in my view model later.

In your example if I put Club and Players together inside another entity like Summary how to achieve 3 levels of hirarchy having usecase id and task id as primary key(relationship between my Usecase,Teature and Task entities).So I am binding Summary.UsecaseList in xaml and I am getting that in UI but Summary.FeatureList and Summary.TaskList(2nd and 3rd levels.You can refer my .xaml file in this forum above) I am not getting.How to achieve this.Please help.
 
public class Summary
    {
        [DataMember]
        public IList<UseCase> UseCaseList { get; set; }
        [DataMember]
        public IList<Feature> FeatureList { get; set; }
        [DataMember]
        public IList<Task> TaskList { get; set; } 
    }
My view model is this:

public class SummaryViewModel : ViewModelBase
    {
        #region Class Members
        private IEventAggregator _ieventAggregator;
        private ICockpitSummaryTabService _iCockpitSummaryTabService;      
        #endregion

        #region Dependency Injection
        [Dependency]
        public IEventAggregator ieventaggregator
        {
            get
            {
                return _ieventAggregator;
            }
            set
            {
                _ieventAggregator = value;
                this.ieventaggregator.GetEvent<ProjectSelected>().Subscribe(OnProjectSelect);
            }
        }      

        [Dependency]
        public ICockpitSummaryTabService iCockpitSummaryTabService
        {
            get
            {
                return _iCockpitSummaryTabService;
            }
            set
            {
                _iCockpitSummaryTabService = value;
            }
        }

        #endregion

        #region void OnProjectSelect(Project projectParam)
        /// <summary>
        /// This event will be fired from project on selection change of projectlist module with selected project.
        /// </summary>
        /// <param name="projectParam">selected project value</param>
        public void OnProjectSelect(Project projectParam)
        {
            if (projectParam != null)
            {
                this._iCockpitSummaryTabService.GetSummary(projectParam, OnSummaryLoadComplete);
            }

        }
        #endregion

        #region void OnSummaryLoadComplete(Summary summary)
        /// <summary>
        /// After capturing the data from the WCF service
        /// </summary>
        /// <param name="summary"></param>
        private void OnSummaryLoadComplete(Summary summary)
        {
            Summary = summary;
           
            /*ObservableCollection<UseCase> tempUsecaseCollection = new ObservableCollection<UseCase>();

            var UseCaseCollection = from u in summary.UseCaseList
                                    select u;

            var FeatureCollection1 = from u in summary.UseCaseList
                                     join f in summary.FeatureList
                                     on u.UseCaseId equals f.UseCaseId
                                     select new { f };

            var TaskCollection1 = from t in summary.TaskList
                                  from f in summary.FeatureList
                                  where f.FeatureID == t.FeatureID
                                  select t;

            ObservableCollection<Feature> tempFeature = new ObservableCollection<Feature>();
            ObservableCollection<Task> tempTask = new ObservableCollection<Task>();*/
          
            OnPropertyChanged("UsecaseCollection");
            OnPropertyChanged("FeatureCollection");
            OnPropertyChanged("TaskCollection");
            OnPropertyChanged("Summary");
        }
        #endregion

        #region PROPERTIES
        public Summary Summary
        {
            get;
            set;
        }
        public ObservableCollection<UseCase> UsecaseCollection
        {
            get;
            set;
        }
        public ObservableCollection<Feature> FeatureCollection
        {
            get;
            set;
        }
        public ObservableCollection<Task> TaskCollection
        {
            get;
            set;
        }
        #endregion
    }


0
Maya
Telerik team
answered on 15 Oct 2010, 10:40 AM
Hi sulagna,

I am sending you a sample project illustrating how to fill up your hierarchical RadGridView with data. Fell free to change it in the way you want and let me know if there is some misunderstandings according to your requirements.

Kind regards,
Maya
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
sulagna
Top achievements
Rank 1
answered on 20 Oct 2010, 03:54 PM
Hi Maya,
Thanks for sharing that code sample but wasn't able to build that and application gives some framework errors and crashes.
I modified my view model like this

 #region void OnSummaryLoadComplete(Summary summary)
        /// <summary>
        /// After capturing the data from the WCF service
        /// </summary>
        /// <param name="summary"></param>
        private void OnSummaryLoadComplete(Summary summary)
        {
            Summary = summary;

            var UseCaseCollection = from u in summary.UseCaseList
                                    select u;

                  select new { f };
          
            ObservableCollection<Feature> tempFeature = new ObservableCollection<Feature>();
            ObservableCollection<Task> tempTask = new ObservableCollection<Task>();
            ObservableCollection<UseCase> tempUsecaseCollection = new ObservableCollection<UseCase>();

          

            tempTask = new ObservableCollection<Task>(summary.TaskList);

            foreach (UseCase usecase in UseCaseCollection)
            {
                var featureCollection = (from feature in Summary.FeatureList
                                         where feature.UseCaseId == usecase.UseCaseId
                                         select feature);
                foreach (Feature feature in summary.FeatureList)
                {
                    var taskCollection = (from task in Summary.TaskList
                                          where task.FeatureID == feature.FeatureID
                                          select task);
                    feature.TaskCollection = new List<Task>(taskCollection);
                }
                usecase.FeatureCollection = new List<Feature>(featureCollection);
                tempUsecaseCollection.Add(usecase);
            }
            UsecaseCollection = tempUsecaseCollection;
            OnPropertyChanged("UsecaseCollection");
            OnPropertyChanged("FeatureCollection");
            OnPropertyChanged("TaskCollection1");
            OnPropertyChanged("Summary");
        }
        #endregion

        #region PROPERTIES
        public Summary Summary
        {
            get;
            set;
        }
        public ObservableCollection<UseCase> UsecaseCollection
        {
            get;
            set;
        }
        public ObservableCollection<Feature> FeatureCollection
        {
            get;
            set;
        }
        public ObservableCollection<Task> TaskCollection1
        {
            get;
            set;
        }
        #endregion
    }

my xaml is

 <telerik:RadGridView x:Name="RadUseCaseGridView" 
                             CanUserFreezeColumns="False" GridLinesVisibility="Horizontal"
                             ItemsSource="{Binding UsecaseCollection}"
                             RowLoaded="RadUseCaseGridView_RowLoaded"                           
                             IsReadOnly="True" AutoGenerateColumns="False">

            <telerik:RadGridView.ChildTableDefinitions>
                <telerik:GridViewTableDefinition>
                    <telerik:GridViewTableDefinition.Relation>
                        <telerik:PropertyRelation ParentPropertyName="Summary.UseCaseList" />
                    </telerik:GridViewTableDefinition.Relation>
                </telerik:GridViewTableDefinition>
            </telerik:RadGridView.ChildTableDefinitions>

            <telerik:RadGridView.Columns >
                <telerik:GridViewDataColumn  DataMemberBinding="{Binding UseCaseId}" Header="UseCase id" />
                <telerik:GridViewDataColumn  DataMemberBinding="{Binding UseCaseNum}" Header="UseCase Number" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseName}" Header="UseCase Name" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseStatus}" Header="UseCase Status" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding UseCaseDesc}" Header="UseCase Description" />
            </telerik:RadGridView.Columns>

            <telerik:RadGridView.HierarchyChildTemplate>

                <DataTemplate>
                    <telerik:RadGridView x:Name="RadFeatureGridView"
                                         RowLoaded="RadFeatureGridView_RowLoaded"
                                         CanUserFreezeColumns="False"
                                         AutoGenerateColumns="False"
                                         ItemsSource="{Binding FeatureCollection}"
                                         ShowGroupPanel="False" IsReadOnly="True">

                        <telerik:RadGridView.ChildTableDefinitions>
                            <telerik:GridViewTableDefinition>
                                <telerik:GridViewTableDefinition.Relation>
                                    <telerik:PropertyRelation ParentPropertyName="Summary.FeatureList" />
                                </telerik:GridViewTableDefinition.Relation>
                            </telerik:GridViewTableDefinition>
                        </telerik:RadGridView.ChildTableDefinitions>

                        <telerik:RadGridView.Columns >
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureID}" Header="Feature id" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureNumber}" Header="Feature Number" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureName}" Header="Feature Name"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureStatusName}" Header="Feature Status"  />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureEstimate}" Header="Reference Estimate" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding ReviseEstimate}" Header="Revised Size Estimate"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding PercentageCompleted}" Header="% Completed" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding FeaturePriority}" Header="Criticality" />
                        </telerik:RadGridView.Columns>

                        <telerik:RadGridView.HierarchyChildTemplate>

                            <DataTemplate>

                                <telerik:RadGridView x:Name="RadTaskGridView" 
                                                     CanUserFreezeColumns="False"
                                                     RowLoaded="RadTaskGridView_RowLoaded"
                                                     AutoGenerateColumns="False"
                                                     ItemsSource="{Binding TaskCollection1}"
                                                     ShowGroupPanel="False" IsReadOnly="True">

                                                                      <telerik:RadGridView.Columns >
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding FeatureID}" Header="Feature id" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskNumber}" Header="Task #" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskName}" Header="Task Name"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskStatus}" Header="Task Status" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ResourceName}" Header="Owner"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ScheduledEffort}" Header="Scheduled Effort" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ActualEffort}" Header="Actual Effort"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding RemainingEffort}" Header="Remaining Effort" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding IterationName}" Header="Iteration Name"/>
                                    </telerik:RadGridView.Columns>

                                </telerik:RadGridView>
                            </DataTemplate>

                        </telerik:RadGridView.HierarchyChildTemplate>

                    </telerik:RadGridView>
                </DataTemplate>

            </telerik:RadGridView.HierarchyChildTemplate>

        </telerik:RadGridView>


Till second level I am getting but 3rd level I am not getting.Please help.This is very urgent.

Regards
Sulagna

0
Maya
Telerik team
answered on 21 Oct 2010, 08:24 AM
Hi sulagna,

There should be no reason for you not to be able to run the application I sent. What kind of errors are you getting? 
Looking at the code-snippet you provide, I cannot see any obvious reason for you not to be able to load the data in the third hierarchy. Are the items not displayed at all or you cannot set even an empty grid in the third level of the hierarchy ? Can follow up if all the Relation properties are set correctly and that all the required data is retrieved from the database ?

 

Sincerely yours,
Maya
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
sulagna
Top achievements
Rank 1
answered on 21 Oct 2010, 10:24 AM
Hi Maya,
Thank you so much for helping me.1st and 2nd level hirarchy grid I was able to see but 3rd no data in grid.
Anyways my problem got resolved.I binded TaskCollection directly without handling that in view model and it started working.
 
Another problem I am facing is I need to handle events in view model instead of xaml.cs file.I am using Row_Loaded event and registering in xaml.So how can I do that? So is there any way I can do that?

Below is the code of xaml.cs

public partial class SummaryView : UserControl
    {
        public static Color InProgress = Color.FromArgb(255,255, 255, 191);
        public static Color Completed = Color.FromArgb(255,208, 255, 208);
        public static Color Postponed = Color.FromArgb(255,255, 202, 202);      
        public static Color NotPlanned = Color.FromArgb(255,230, 255, 255);
        public static Color NotStarted = Color.FromArgb(255,255, 255, 255);
        IUnityContainer _container;
       
        public SummaryView()
        {
            InitializeComponent();          
            DataContext = Container.Resolve<SummaryViewModel>();
        }
        private IUnityContainer Container
        {
            get
            {
                if (_container == null)
                    _container = ServiceLocator.Current.GetInstance<IUnityContainer>();
                return _container;
            }
        }
        //Event for setting colours dynamically

        private void RadUseCaseGridView_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            GridViewRow row = e.Row as GridViewRow;

            if (e.Row is GridViewRow)
            {
              
                if (row.Cells.Count > 2)

                    if (row.Cells[2] != null)
                    {
                        if (((System.Windows.Controls.TextBlock)(row.Cells[2].Content)).Text == "In Progress")
                        {
                            row.Background = new SolidColorBrush(InProgress);                         

                        }                       
                        if (((System.Windows.Controls.TextBlock)(row.Cells[2].Content)).Text == "Not Planned")
                        {
                            row.Background = new SolidColorBrush(NotPlanned);                          

                        }
                        if (((System.Windows.Controls.TextBlock)(row.Cells[2].Content)).Text == "Not Started")
                        {
                            row.Background = new SolidColorBrush(NotStarted);
                        }
                       
                        if (((System.Windows.Controls.TextBlock)(row.Cells[2].Content)).Text == "Postponed")
                        {
                            row.Background = new SolidColorBrush(Postponed);
                        }
                        if (((System.Windows.Controls.TextBlock)(row.Cells[2].Content)).Text == "Completed")
                        {
                            row.Background = new SolidColorBrush(Completed);
                        }
                      
                    }              
            }           
        }

    }


0
Maya
Telerik team
answered on 21 Oct 2010, 11:53 AM
Hi sulagna,

The basic idea behind the Model-View-ViewModel Design Pattern is to separate the view from the data, using the ViewModel. Thus, handling the RowLoaded event inside the ViewModel and making it aware of the visual elements in the application breaks the whole idea behind that pattern and goes beyond its concept.
Furthermore, on looking at the code-snippet provided, I may suggest to you a couple of things for improving it. Firstly, working directly with the content of a visual item - in your case with a cell - is not a good practice and it may cause some unexpected results and behavior due to the enabled virtualization. I would recommend to work directly with the underlaying data - meaning directly with the Properties, defined in the class. 
Considering the changes you want to apply to the rows, you may try to implement a RowStyleSelector as demonstrated in our demos.

 

Sincerely yours,
Maya
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
sulagna
Top achievements
Rank 1
answered on 22 Oct 2010, 08:53 PM
Hi Maya,

Your suggestions are quite helpful and valid. Earlier I did the same way as you suggested view-viewmodel-model but dont know why it was suggested by out architect...Anyways will communicate the same.
He suggested there should not be anything/min coding in xaml.cs file unless and untill needed.
Our current approach if there is any event handling in xaml.cs file then its registered in xaml.cs like below code and moved that to view model.Now the problem is my parent grid is holding colours but child grids are not holding even though it sets colour at run time. RadGridView is the name of the grid.I have used the same name in all 3 grids.  
Using view-viewmodel-model it works fine..
public SummaryView()
        {
            InitializeComponent();          
            DataContext = Container.Resolve<SummaryViewModel>();
            SummaryViewModel summaryViewModel = new SummaryViewModel();
            RadGridView.RowLoaded +=
new  EventHandler<RowLoadedEventArgs>summaryViewModel.RadUseCaseGridView_RowLoaded);
}
I have attached the screen shot of the grid for your reference

Thanks,
Sulagna 
0
Maya
Telerik team
answered on 25 Oct 2010, 09:45 AM
Hello sulagna,

The reason for the Background color not to be applied in the children grids is that the RowLoaded event is called only for the parent RadGridView. However, looking at the code-snippet you provided, I may suggest to you to use a RowStyleSelector as described in our online documentation and demonstrated in our demos.
 

Greetings,
Maya
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
sulagna
Top achievements
Rank 1
answered on 25 Oct 2010, 11:49 AM

Hi Maya,
    Inside hirarchy grid view the grid view contains another grid view in it's GridView.HierarchyChildTemplate <DataTemplate >(Refer code below).In the xaml.cs i tried to access the inner grid using the x:Name but it's not identified. How can i identify it in code behind. Not only for the inner grid, but also for another inner grid for all these i have x:Name, but cannot assign a value to it's properties

How can i get the control "featureGrid" in xaml.cs ?

<telerik:RadGridView.HierarchyChildTemplate>

                            <DataTemplate >

                                <telerik:RadGridView x:Name="featureGrid"
                                                     CanUserFreezeColumns="False"                                                      
                                                     AutoGenerateColumns="False"
                                                     ItemsSource="{Binding TaskCollection}"
                                                     ShowGroupPanel="False" IsReadOnly="True">

                                    <telerik:RadGridView.Columns >
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskNumber}" Header="Task #" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskName}" Header="Task Name"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskStatus}" Header="Task Status" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ResourceName}" Header="Owner"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ScheduledEffort}" Header="Scheduled Effort" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding ActualEffort}" Header="Actual Effort"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding RemainingEffort}" Header="Remaining Effort" />
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding IterationName}" Header="Iteration Name"/>
                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TaskDesc}" Header="Task Description"/>
                                    </telerik:RadGridView.Columns>

                                </telerik:RadGridView>
                            </DataTemplate>

</telerik:RadGridView.HierarchyChildTemplate>

Thanks,
Sulagna

0
Vlad
Telerik team
answered on 25 Oct 2010, 11:57 AM
Hi,

 You cannot accessed them directly since they are in different name scope - you can use however their Loaded events (sender is the UI element itself). 

All the best,
Vlad
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
sulagna
Top achievements
Rank 1
answered on 25 Oct 2010, 12:50 PM
Hi,
I am trying to get the 1st element means the nested grid of the parent grid but throwing runtime error.Please help me to resolve this.Its very urgent.How can I get the 2st level grid in the hirarchy in .cs file?I am doing like this  _radGridView = e.Row.ChildrenOfType<RadGridView>()[0];

public void RadGridViewusecase_RowLoaded(object sender, RowLoadedEventArgs e)
        {
           RadGridView _radGridView = e.GridViewDataControl as RadGridView;
           if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))  
           {
               _radGridView = e.Row.ChildrenOfType<RadGridView>()[0];
           }
        }
Thanks
Sulagna
0
sulagna
Top achievements
Rank 1
answered on 25 Oct 2010, 01:26 PM

Hi,
I am trying to get the 1st element means the nested grid of the parent grid but throwing runtime error.Please help me to resolve this.Its very urgent.How can I get the 2st level grid in the hirarchy in .cs file?I am doing like this  _radGridView = e.Row.ChildrenOfType<RadGridView>()[0];

public void RadGridViewusecase_RowLoaded(object sender, RowLoadedEventArgs e)
        {
           RadGridView _radGridView = e.GridViewDataControl as RadGridView;
           if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))  
           {
               _radGridView = e.Row.ChildrenOfType<RadGridView>()[0];
           }
        }
Can I use this link for resolving this issue "http://blog.functionalfun.net/2008/09/hooking-up-commands-to-events-in-wpf.html"
Thanks
Sulagna

Tags
GridView
Asked by
sulagna
Top achievements
Rank 1
Answers by
Maya
Telerik team
sulagna
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or