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

How to Hide/Disable unwanted buttons in Expression Editor?

10 Answers 150 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 16 Aug 2011, 07:49 PM

Dear Community,

Is it possible to hide/disable some of the buttons of expression editor programatically? Actually, we just want to keep some of the basic operators like +, -, * and / and would like to hide/disable rest of the buttons.

We would also like to hide/disable some of the nodes of the tree view that lists opertors or may be some of the childs/items of a node. Is this also possible?

Please share your comments/code snippet with us as soon as possible.

Regards,
Shiva

10 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 16 Aug 2011, 08:46 PM
Hello Shiva,

 You can modify the template of RadExpressionEditor to remove buttons you don't want. Also, calling the ChildrenOfType<RadButton>() extension method on RadExpressionEditor will return all the buttons in the editor so you can modify their Visibility property.

 Unfortunately, there is no way to change what nodes appear in the tree.

All the best,
Yavor Georgiev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Shiva
Top achievements
Rank 1
answered on 17 Aug 2011, 07:10 AM
Dear Yavor,

Thanks for your reply on my query. I was trying using the second option suggested by you i.e. calling the ChildrenOfType<RadButton>() extention method to get the list of all buttons.

However, the problem is that below statement returns me null list:

IList<RadButton> lstButton = expData.ChildrenOfType<RadButton>();

I have this statement in the constructor of my silverlight page. However, if I write this statement in 'ExpressionChanged" event of expression editor, it works. I get list of all buttons using above code in this event method. But I would like to show some of the buttons disabled when page loads so that user cannot select those buttons. Above code works in 'ExpressionChanged" event which I don't want.

It would be great if you could please also use a code snippet in your response.

Regards,
Shiva
0
Accepted
Yavor Georgiev
Telerik team
answered on 17 Aug 2011, 07:47 AM
Hello Shiva,

 You should use the Loaded event of the RadExpressionEditor, which guarantees that it will have had time to load its template. Just to be extra safe, you can also use a Dispatcher, to make sure that at least one layout pass has occurred. Place this code in the handler for the Loaded event of RadExpressionEditor:
Dispatcher.BeginInvoke(() =>
{
    foreach (var button in this.radExpressionEditor1.ChildrenOfType<RadButton>())
    {
         if (button.Content.ToString() != "+")
         {
             button.Visibility = Visibility.Collapsed;
         }
    }
});

 Please let me know if you have any further inquiries.

Kind regards,
Yavor Georgiev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Shiva
Top achievements
Rank 1
answered on 17 Aug 2011, 08:20 AM
Dear Yavor,

I had placed the code in the loaded event as well but it didn't work.

As mentioned in your reply, I used Dispatcher in the loaded event and then it worked. So basically the problem is resolved but I still belive that it should have worked without using Dispatcher as Loaded event means that expression editor has loaded its full state.

Is there any performance issue with using Dispatcher on my page?

Regards,
Shiva
0
Yavor Georgiev
Telerik team
answered on 17 Aug 2011, 09:35 AM
Hi Shiva,

 The Loaded event hits when the ControlTemplate is loaded - it does not guarantee that all the UI elements will be realized, hence the call to Dispatcher.BeginInvoke.

 Dispatcher does not introduce any performance penalties - it only ensures that the dispatched code will be executed on the UI thread, after the next layout pass. Also, you're calling Dispatcher.BeginInvoke only in the Loaded event, so even if any performance hit existed, it would be negligible.

Regards,
Yavor Georgiev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Shiva
Top achievements
Rank 1
answered on 23 Aug 2011, 05:51 AM
Dear Yavor,

Is there any indirect/alternate way to hide tree view nodes of the expression editor. You have above mentioned in your response that we can only hide buttons but not the nodes of tree view.

Any way to tweek this behaviour of Telerik Expression Editor??

Regards,
Shiva
0
Stefan Dobrev
Telerik team
answered on 23 Aug 2011, 02:03 PM
Hello Shiva,

Currently we do not support hiding specific nodes in the tree view. There is a work-around you can implement again using ChildrenOfType method and setting the visibility of the specified tree nodes you want to hide to collapsed. However this is not a solution I'm going to rely on because there is a huge chance that we broke your code with some future version of the control. This is totally unsupported way (do on your own risk) and you should be very careful if you decide to do so.

Hope this helps,
Stefan Dobrev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Kiti
Top achievements
Rank 1
answered on 23 Dec 2011, 01:12 PM
Hello Telerik Team, 

I want to add an extra node calling 'Country' and 'PriceType' in the tree node of RadExpressionEditor window replacing Filelds node.

Clicking on Country will show the list of countries in the right panel, i.e, the panel which is used for listing the functions,constants, etc and clicking on PriceType will show the list of price types.

The content of the node will be dynamic, i.e, the list of the countries will come from database. 

My projects requirement is to add extra node in the same tree node. Will it be possible in any future release?

If yes, can you please send me a sample code for the same. 

Reply me asap.

Regards,
Kiti
0
Jarred Froman
Top achievements
Rank 1
answered on 02 Mar 2012, 03:59 PM
We are interested in implementing a similar type of functionality that Kiti mentioned.  Is this currently possible, and if not, is there a workaround?

Thanks,
Jarred
0
Vlad
Telerik team
answered on 05 Mar 2012, 03:51 PM
Hello,

 Currently this is not possible and we do not have any immediate plans to support for this. 

Greetings,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ExpressionEditor
Asked by
Shiva
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Shiva
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Kiti
Top achievements
Rank 1
Jarred Froman
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or