We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridTreeControl & Children of *different* types

Thread ID:

Created:

Updated:

Platform:

Replies:

117823 Dec 22,2014 03:20 PM UTC Mar 30,2018 07:32 AM UTC WPF 12
loading
Tags: GridTreeControl
Adam Smith
Asked On December 22, 2014 03:20 PM UTC

I am trying to implement a hierarchical GridTreeControl whereby the children are of differing types, albeit within the same inheritance hierarchy.

This doesn't appear to work, with the grid throwing an exception stating "Object does not match target type".  Does this mean all children have to be of the same type?

Example - Model Structure

public abstract class ItemWithChild
{
   List<ItemWithChild> Children {get; set;}
}

public class Director : ItemWithChild
{
    // Director specific properties
}

public class TeamLead: ItemWithChild
{
    // Team Lead specific properties
}

Example XAML

            <syncfusion:GridTreeControl x:Name="treeGrid"
                                        ExpandStateAtStartUp="AllNodesExpanded"
                                        ItemsSource="{Binding Employees}"
                                        ChildPropertyName="Children"      <!-- Bind to common property in base class -->
                                        ReadOnly="True">

Please outline how I can implement the above.  In addition, I'd like to provide a separate template for each type - (are HierarchicalDataTemplate's supported for this purpose, or something similar)?

- Adam

Jai Ganesh S [Syncfusion]
Replied On December 31, 2014 12:25 PM UTC

Hi Adam,

Thank you for using Syncfusion products.

We have analyzed your query. We regret to inform you that we don’t have a support to add a different child types in GridTreeControl. Hence the exception was raised. Could you please share more details or a snap shot for your requirement? This would be more helpful for us to serve you in better.

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



Adam Smith
Replied On January 2, 2015 09:08 AM UTC

Hi Jai,

Thanks for your response - despite the disappointing outcome.

As for your question...
"Could you please share more details or a snap shot for your requirement?"

I believe the subject line covers this adequately.  

If you're still in need of some inspiration, check out the equivalent Infragistics Dev Express "tree grid" controls - they both provide this functionality.

- Adam


Jai Ganesh S [Syncfusion]
Replied On January 6, 2015 03:28 PM UTC

Hi Adam,

Thank you for the update.

As we mentioned in the last update, we don’t have a support to add different children types in GridTreeControl by using the code snippet provided by you. However you can add different child types by adding a datas through work around. We have prepared the sample based on this and please find the sample under the following location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/117823/GTC_HierarchicalData-605843145.zip

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



Adam Smith
Replied On January 6, 2015 03:44 PM UTC

Hi Jai,

"However you can add different child types by adding a datas through work around. We have prepared the sample based on this..."

I've taken a look at the sample you provided.  It still doesn't demonstrate how to add different child types - they are all of type "BusinessObject"?

- Adam


Jai Ganesh S [Syncfusion]
Replied On January 20, 2015 11:37 AM UTC

Hi Adam,

Sorry for the delayed response.

We have already mentioned in our previous updates that our GridTreeControl does not directly support to add different child types. But you can achieve this requirement by setting different type of properties as GridTreeUnBoundColumns and set the values for UnBoundColumns through QueryUnboundCellInfo event. We have prepared the sample based on this and please find the sample under the following location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/GridTreeSample2059116872.zip

Note:

In the above sample we have created the EmployeeCity, EmployeeDesignation as GridTreeUnboundColumns and set the values for this columns through QueryUnboundCellInfo event.

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



Adam Smith
Replied On January 26, 2015 03:02 PM UTC

Hi Jai,

Have you actually ran this demo?  

The values in EmployeeCity and EmployeeDesignation randomly change as you hover over them as you've not linked the unbound columns to the underlying data model.

As such, this demo is useless and demonstrates nothing of any value.

- Adam

Adam Smith
Replied On January 26, 2015 03:15 PM UTC

I've fixed the demo to bind to the underlying model.  However, with them being unbound columns there's no way to edit the cell such that the underlying model is updated.  

Can you please demonstrate how this can be achieved?

Fixed Demo Code:

        void InternalGrid_QueryUnboundCellInfo(object sender, GridTreeUnboundCellInfoEventArgs Args)
        {
            GridTreeNode record = treeGrid.InternalGrid.GetNodeAtRowIndex(Args.Cell.RowIndex);
            
            switch (Args.Column.MappingName)
            {
                case "EmployeeCity":
                    var person1 = record.Item as Person1;
                    if (person1 != null)
                    {
                        Args.Style.CellValue = person1.EmployeeCity;
                    }
                    break;
                case "EmployeeDesignation":
                    var person2 = record.Item as Person2;
                    if (person2 != null)
                    {
                        Args.Style.CellValue = person2.EmployeeDesignation;
                    }
                    break;
            }
        }

Jai Ganesh S [Syncfusion]
Replied On January 27, 2015 06:44 PM UTC

Hi Adam,

We regret to inform you that we will not update the edited values of UnboundColumn. The UnboundColumns are not in business object and it is not belong to the data source. Please refer the following UG link to know more details about UnboundColumns,

UG Link:

http://help.syncfusion.com/ug/wpf/default.htm#!documents/unboundcolumns2.htm

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



Adam Smith
Replied On January 28, 2015 08:29 AM UTC

Hi,

Thanks for your response.

Will these issues be fixed in future versions?

- Adam

Jai Ganesh S [Syncfusion]
Replied On January 29, 2015 04:15 PM UTC

Hi Adam,

Please ignore the previous update.

Currently our GridTreeControl not supported to update the edited values in UnboundColumn directly but we can achieve this by through work around. We have prepared the sample based on this and please find the sample under the following location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/GridTreeSample513585299.zip

In the sample we have used CurrentCellValidating event to update the edited values in UnBoundColumn.

Code Snippet [C#]:

treeGrid.InternalGrid.CurrentCellValidating += InternalGrid_CurrentCellValidating;

void InternalGrid_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e)

        {

            GridTreeNode record = treeGrid.InternalGrid.GetNodeAtRowIndex(e.Style.RowIndex);

           

            var columnindex = this.treeGrid.InternalGrid.ResolveIndexToColumnIndex(e.Style.ColumnIndex);

            if (this.treeGrid.Columns[columnindex].MappingName == "EmployeeCity")

            {

                var person1 = record.Item as Person1;

                if (person1 != null)

                {

                    person1.EmployeeCity = e.NewValue.ToString();

                }

            }

            else if (this.treeGrid.Columns[columnindex].MappingName == "EmployeeDesignation")

            {

                var person2 = record.Item as Person2;

                if (person2 != null)

                {

                    person2.EmployeeDesignation = e.NewValue.ToString();

                }

            }

       }

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



Willie Wang
Replied On March 28, 2018 11:02 AM UTC

Hi Jai,

Have you actually ran this demo?  

The values in EmployeeCity and EmployeeDesignation randomly change as you hover over them as you've not linked the unbound columns to the underlying data model.

As such, this demo is useless and demonstrates nothing of any value.

- Adam

22222

Jai Ganesh S [Syncfusion]
Replied On March 30, 2018 07:32 AM UTC

Hi Willie, 
 
We have already addressed this issue in our previous updates. Could you please let us know your requirements in detail for assistance? 
 
Regards, 
Jai Ganesh S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;