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

Hierarchy and IsExpandable

13 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Wang
Top achievements
Rank 1
Wang asked on 01 Feb 2016, 02:37 AM

Hello!

I have a question about Hierarchy and IsExpandable, In my GridView ,user can add and remove father and son items.

I tried the code like this two way,they can set  IsExpandable to false or true when loaded or add items,

but when I remove all the sub items of a father item, the IsExpandable can not set to false,is there any way to solve it? thanks a lot.

<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow">
   <Setter Property="IsExpandable" Value="True"/>
   <Style.Triggers>
    <DataTrigger Binding="{Binding Converter={StaticResource integerToBooleanConverter}, Path=SubList.Count}" Value="False">
    <Setter Property="IsExpandable" Value="False"/>
    </DataTrigger>
    </Style.Triggers>
 </Style>
 </telerik:RadGridView.RowStyle>
<i:Interaction.Behaviors>
  <behavior:IsExpandableBehavior IsExpandableSourcePropertyName="SubList.Count" />
 </i:Interaction.Behaviors>

13 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 03 Feb 2016, 02:43 PM
Hello,

As it turns out, there's an issue with the expanding of RadGridView that breaks the binding to the IsExpandable property. I've logged this in our system and you can follow the process of fixing it in our feedback portal. As a thank you for helping us find this issue, I've awarded you with some Telerik points.

I've attached a sample project, showing how you can achieve the desired behaviour through a style selector. Please let me know if this workaround works for you.

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 04 Feb 2016, 03:17 AM

hello Dilyan Traykov,

Thanks for your demo,it worked fine!

but in my project, the gridrow can be drag & drop to order,so I set RowStyle like this:

<telerik:RadGridView.RowStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" />
                    <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/>
                    <Setter Property="IsExpandable" Value="True"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Converter={StaticResource integerToBooleanConverter}, Path=SubList.Count}" Value="False">
                            <Setter Property="IsExpandable" Value="False"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </telerik:RadGridView.RowStyle>
 and set RowStyleSelector before the RowStyle.

then,the grid can be  drag & drop, but can't set  IsExpandable accurately.

can you tell me how to fix it? thank you very much!

 

 

0
Wang
Top achievements
Rank 1
answered on 04 Feb 2016, 03:26 AM

And is it possible to write a common class like your MyStyleSelector class?  

improve the code:

if ((item as Division).Teams.Count > 0)

to a common way?

 

0
Dilyan Traykov
Telerik team
answered on 08 Feb 2016, 03:45 PM
Hello Wang,

Another solution I can offer is to handle the Deleted event of the GridView and set the IsExpandable property there:

private void parentGrid_Deleted(object sender, GridViewDeletedEventArgs e)
{
    var childGrid = e.OriginalSource as RadGridView;
    if (childGrid.Items.Count == 0)
    {
        childGrid.ParentRow.IsExpanded = false;
        childGrid.ParentRow.IsExpandable = false;
    }
}

I've attached a sample project, showing you how to implement this. Let me know whether this approach works for you.

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 18 Feb 2016, 07:45 AM

Hello Dilyan Traykov,

I tried your demo,when I deleted all the sub items of first row, the IsExpandable of first row setted to false,

but when I deleted all the sub items of second row too,the IsExpandable of first row setted to ture.

so in the grid,only one row's IsExpandable  can be setted to false in this demo.

can you resolve it?

Another quistion: RowStyleSelector and RowStyle can't be used in one gridview?

0
Dilyan Traykov
Telerik team
answered on 22 Feb 2016, 01:33 PM
Hello Wang,

The behavior you're experiencing is due to RowVirtualization. Disabling it fixes the issue, but I should warn you that this is highly unrecommended as it leads to degraded performance.

Regarding your second question - the RowStyle and RowStyleSelector are not meant to work together. As you have probably seen, the RowStyleSelector is overwritten by the RowStyle. The same behavior is observed with the standard MS controls. So I'm afraid there is no way to apply both.

Could you please specify the scenario in which you would like to use them? Maybe I can provide you with a solution using just one.

Feel free to approach me with any further questions you might have.

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 23 Feb 2016, 03:13 AM

Hello Dilyan Traykov,

In my project,

1.I should write a RadGridView with three layers hierarchy.

2.User can click buttons in toolbar to add\edit\delete items of all layers.

3.User can drag & drop a item between same layer  to order the data.

4.If one row has no subItems or subItems are deleted, set the IsExpandable to false.

that are all I want to achieve, waiting your solution eagerly! thank you!

0
Dilyan Traykov
Telerik team
answered on 24 Feb 2016, 12:27 PM
Hello Wang,

I seem to have found a solution for your scenario without the need to disable virtualization. It incorporates both previous approaches and relies on both a RowStyleSelector and the Deleted event. I've attached the sample project to my reply. Please take a look at it and let me know whether this behavior is satisfactory for you.

Do let me know if any further questions arise.

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 25 Feb 2016, 07:32 AM

Hello Dilyan Traykov,

It worked fine when I delete all the sub items of one row as A,but when I add a sub item to the SubList of A by click a button,the IsExpandable was always false,so I can not see the sub item added.

before I use the demo,when I add a sub item to the SubList of A, the IsExpandable was set to true,and the gridview would add a subgrid newrow automatically.

I think if I do something in the add sub item button click event, to set IsExpandable to true of the gridrow, it will work fine,but I use MVVM, I do not want to operate View in ViewModel, is there some other solution to solve it perfectly?

0
Dilyan Traykov
Telerik team
answered on 26 Feb 2016, 03:40 PM
Hello,

I'm afraid this is the only solution I can offer you at the moment until we fix the binding issue.

You can follow the item in our feedback portal in order to get notified when the bug is fixed.

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 29 Feb 2016, 01:23 AM

Hello Dilyan Traykov,

Thanks for your reply.

I have another problem,I was disturbed about the drag & drop in Hierarchy, I want to drag & drop a item between same layer  to order the data in Hierarchy.

I have seen the toppic , but I have no idea to remodify it, could you do me a favor to send me a sample project, show me how to do that? thank you a lot! best wishes!

0
Dilyan Traykov
Telerik team
answered on 01 Mar 2016, 03:26 PM
Hello Wang,

I'm attaching a sample project, that implements the desired behavior. Feel free to modify it to your liking.

I noticed that you have opened another thread regarding the same question where one of my colleagues has responded. Could you please take a look at it as well?

Regards,
Dilyan Traykov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Wang
Top achievements
Rank 1
answered on 04 Mar 2016, 08:49 AM
Thank you for the answers and the code sample. I'll give it a try and see how it goes.
Tags
GridView
Asked by
Wang
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Wang
Top achievements
Rank 1
Share this question
or