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
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 >>
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
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 >>
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
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 >>
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
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 >>
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
Thanks,
Jarred
Currently this is not possible and we do not have any immediate plans to support for this.
Greetings,Vlad
the Telerik team