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

Expand/Collapse node when IsEnable is set to false

Thread ID:

Created:

Updated:

Platform:

Replies:

143337 Mar 14,2019 04:07 PM UTC Mar 21,2019 12:30 PM UTC WPF 10
loading
Tags: SfTreeGrid
Michele
Asked On March 14, 2019 04:07 PM UTC

Hi
I need to disable the cell editing of a TreeGridExpanderCell but in the same time i need to allow expand/collapse function.
How can i modify my xaml if is it possible?

        <Style TargetType="syncfusion:TreeGridExpanderCell">
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="IsEnabled" Value="{Binding IsKeyEditable}"/>
        </Style>


               <syncfusion:TreeGridTextColumn HeaderText="Key" MappingName="Key" Width="100" AllowFocus="True">
                    <syncfusion:TreeGridTextColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="VSIcons/Field_16x.png" Width="15" Margin="5,0,0,0"/>
                                <TextBlock Text="{Binding Key}" Margin="7,0,0,0" VerticalAlignment="Center" />
                            </StackPanel>
                        </DataTemplate>
                    </syncfusion:TreeGridTextColumn.CellTemplate>
                </syncfusion:TreeGridTextColumn>


Arulraj A [Syncfusion]
Replied On March 15, 2019 12:33 PM UTC

Hi Michele, 

Thanks for contacting Syncfusion Support. 

We have analyzed your query to restrict the editing operation for TreeGridExpanderCell without affecting expanding/collapsing operation on node. On analyzing your provided code snippet, it seems that you have set TreeGridExpanderCell.IsEnabled as false and because of this setting you were unable to expand/collapse node. You can resolve this by setting TreeGridColumn.AllowEditing property for the expander column as false  instead of setting TreeGridExpanderCell.IsEnabled as false. Please refer to the code snippet below 

<syncfusion:TreeGridTextColumn HeaderText="Key" MappingName="Key" Width="100" AllowFocus="True" AllowEditing="False"
                    <syncfusion:TreeGridTextColumn.CellTemplate> 
                        <DataTemplate> 
                            <StackPanel Orientation="Horizontal"> 
                                <Image Source="VSIcons/Field_16x.png" Width="15" Margin="5,0,0,0"/> 
                                <TextBlock Text="{Binding Key}" Margin="7,0,0,0" VerticalAlignment="Center" /> 
                            </StackPanel> 
                        </DataTemplate> 
                    </syncfusion:TreeGridTextColumn.CellTemplate> 
                </syncfusion:TreeGridTextColumn> 
 
Also please refer to the below UG link to know more details on editing 
UG Link: 
 
Please let us know if you need any further assistance on this. 

Regards, 
Arulraj A 


Michele
Replied On March 15, 2019 01:23 PM UTC

Thanks Arulraj 
My question was not clear, sorry.
I have many TreeGridExpanderCell in my tree, some of them need to be editable and other no, it depends from IsKeyEditable property related to each node in the tree, but all of them need to be expanded/collapsed.
If i bind IsKeyEditable property to the TreeGridTextColumn, the property have effect on entire Column.

I need to expand/collapse TreeGridExpanderCell but i don't want that some of those Cell are editable.

I've try to set the IsEnable property in the style of TreeGridExpanderCell but it locks editing and also expand/collapse. 
<Style TargetType="syncfusion:TreeGridExpanderCell">
     <Setter Property="IsEnabled" Value="{Binding IsKeyEditable}"/>
</Style>

I need a solution silimilar to this:
<Style TargetType="syncfusion:TreeGridExpanderCell">
     <Setter Property="AllowEditing" Value="{Binding IsKeyEditable}"/>
</Style>

But unfortunatly AllowEditing is not a property of TreeGridExpanderCell
How can i resolve or bypass this?

Thanks



Shobika Palani [Syncfusion]
Replied On March 18, 2019 01:10 PM UTC

Hi Michele, 
 
Thanks for the update. 
 
We are currently working on to achieve your requirement to restrict editing based on row data and also to enable expand/collapse option in node. We will update you with further details on 20th March, 
2019. 
 
We will appreciate your patience until then. 
 
Regards, 
Shobika. 


Michele
Replied On March 18, 2019 01:31 PM UTC

Thanks Shobika
I will wait.

Regards
Michele

Arulraj A [Syncfusion]
Replied On March 19, 2019 04:01 AM UTC

Hi Michele,  
  
Thanks for the update.  
  
As promised earlier, we will update you with the details on 20th March 2019.  
  
We will appreciate your patience until then.  

Arulraj A 


Neelakandan Kannan [Syncfusion]
Replied On March 20, 2019 12:43 PM UTC

Hi Michele, 

Thanks for your patience. 

TreeGrid don’t have support to set the editing behavior using TreeGridExpanderCell style. But, this can be achieved by using the CurrentCellBeginEdit event and cancel the editing for the particular node based on the underlying row data.  

public MainWindow() 
{ 
    InitializeComponent(); 
 
    treeGrid.CurrentCellBeginEdit += TreeGrid_CurrentCellBeginEdit; 
} 
 
private void TreeGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.TreeGrid.TreeGridCurrentCellBeginEditEventArgs e) 
{ 
    var treeNode = treeGrid.View.GetNodeAt(e.RowColumnIndex.RowIndex - 1); 
 
    if (treeNode.HasChildNodes) 
    { 
       var data = treeNode.Item as PersonInfo; 
       e.Cancel = !data.LikesCake;                     
    } 
} 

 
Regards, 
Neelakandan 


Michele
Replied On March 20, 2019 02:29 PM UTC

Thanks for the reply. Unfortunatly is not the solution that i'm looking for.
Syncfusion.UI.Xaml.TreeGrid.TreeGridCurrentCellBeginEditEventArgs e) 
{ 
    var treeNode = treeGrid.View.GetNodeAt(e.RowColumnIndex.RowIndex - 1); 
 
    if (treeNode.HasChildNodes) 
    { 
       var data = treeNode.Item as PersonInfo; 
       e.Cancel = !data.LikesCake;                     
    } 
} 
e.Cancel locks entire row, not only the cell.
There is a way to avoid cell editing mantaining expand/collaps behavior?

Thanks


Arulraj A [Syncfusion]
Replied On March 21, 2019 10:48 AM UTC

Hi Michale, 

Sorry for the inconvenience caused. 

You can get the TreeViewExpanderCell type by using the RowGenerator property. As of now, it is an internal property. You can use reflection to access that property. As per you requirement, this works for Expand/collapse cells i.e. Expander cells which has child nodes. Please make use of the following code and sample, 

public MainWindow() 
{ 
     InitializeComponent(); 
 
     treeGrid.CurrentCellBeginEdit += TreeGrid_CurrentCellBeginEdit; 
} 
 
private void TreeGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.TreeGrid.TreeGridCurrentCellBeginEditEventArgs e) 
{           
     var rows = treeGrid.GetType().GetField("RowGenerator", System.Reflection.BindingFlags.NonPublic |  System.Reflection.BindingFlags.Instance).GetValue(treeGrid); 
     List<TreeDataRowBase> treeGridRows = (rows as TreeGridRowGenerator).Items; 
     var treeGridRow = treeGridRows.FirstOrDefault(row => row.RowIndex == e.RowColumnIndex.RowIndex); 
 
     if (treeGridRow == null) 
         return; 
 
     var column = treeGridRow.VisibleColumns[e.RowColumnIndex.ColumnIndex]; 
 
     if (column == null) 
         return; 
 
     if (column.Element is TreeGridExpanderCell && treeGridRow.Node.HasChildNodes) 
     { 
         var data = treeGridRow.RowData as PersonInfo; 
         e.Cancel = !data.LikesCake; 
     } 
} 
 


Let us know whether this helps also if you need any further assistance on this. 

Arulraj A 


Michele
Replied On March 21, 2019 12:21 PM UTC

Many thanks!
It works perfectly!!

Really good support! 
Michele

Arulraj A [Syncfusion]
Replied On March 21, 2019 12:30 PM UTC

Hi Michele, 

Thanks for the update. 

We are glad to know that the provided solution worked at your end. Please let us know if you have any further queries on this. We are happy to help you. 

Arulraj A 


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

This page will automatically be redirected to the 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

;