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

Only allow expressions to be added to groups

6 Answers 92 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Ole
Top achievements
Rank 1
Ole asked on 22 Apr 2021, 03:38 PM

I would like to remove the Group option from the DataFilterAddNodeElement dropdown list when I'm adding to an existing group. Basically I only want to allow adding expressions to groups and prevent nested groups from being created. However, I still want to allow adding groups to the root node, just not to other groups. Is there a way to hide or disable the Group option in this scenario?

Thanks

6 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 22 Apr 2021, 04:22 PM

Hello, Ole,

If I understand your requirement correctly you would like to remove the group option from the RadDataFilter control and allow only expressions. To achieve this you can use the following approach:

this.radDataFilter1.NodeFormatting += this.RadDataFilter1_NodeFormatting;
private void RadDataFilter1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{
    DataFilterAddNodeElement addNodeElement = e.NodeElement as DataFilterAddNodeElement;
    if (addNodeElement != null)
    {
        var dropDownButton = addNodeElement.DropDownButton;
        if (dropDownButton.Items.Count == 2)
        {
            dropDownButton.Items.RemoveAt(0);
        }
    }
}

I hope this helps. Let me know if you have any other questions.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Ole
Top achievements
Rank 1
answered on 22 Apr 2021, 06:03 PM

Thanks Nadya,

How can I tell if the DataFilterAddNodeElement is from the DataFilterRootNode or from a DataFilterGroupElement?

Thanks

0
Nadya | Tech Support Engineer
Telerik team
answered on 23 Apr 2021, 09:43 AM

Hello, Ole,

If you disable the Group option in RadDataFilter control you won't be able to add groups. Hence, you wouldn't be able to have nested groups as well. If you have added just Expressions they will appear as root nodes in the tree, without nested groups. Please see the attached gif file. Am I missing something? In case you have a different set up it would be greatly appreciated if you can provide more information about what is the exact current implementation that you have. A picture or video would be much appreciated.

Looking forward to your reply.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ole
Top achievements
Rank 1
answered on 23 Apr 2021, 01:38 PM

Hello Nadya, 

I have attached a picture that will hopefully help explain the result I'm after. I still want to be able to add groups, but only to the root node and not to other groups. In my attached picture, I want to prevent the node with the red arrow from being added. I still want to allow expressions to be added to group nodes, just not group nodes to other group nodes.

Hopefully this helps.

Thank you,

Ole

0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 26 Apr 2021, 09:31 AM

Hello, Ole,

Thank you for the picture and clarifying that you want to be able to add groups but only to the root nodes. Please refer to the following code snippet that demonstrates how you can achieve this:

private void RadDataFilter1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{
    DataFilterAddNodeElement addNodeElement = e.NodeElement as DataFilterAddNodeElement;
    if (addNodeElement != null)
    {
        if (e.Node.Level > 1)
        {
            var dropDownButton = addNodeElement.DropDownButton;
            if (dropDownButton.Items.Count == 2)
            {
                dropDownButton.Items.RemoveAt(0);
            }
        }
    }
}

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ole
Top achievements
Rank 1
answered on 26 Apr 2021, 02:32 PM

 

That worked perfectly! Thank you Nadya!

Tags
DataFilter
Asked by
Ole
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Ole
Top achievements
Rank 1
Share this question
or