How to Hide/Disable unwanted buttons in Expression Editor?

11 posts, 1 answers
  1. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 16 Aug 2011 Link to this post

    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

  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 16 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    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
  5. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 17 Aug 2011 Link to this post

    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 >>

  6. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2011 Link to this post

    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
  7. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 17 Aug 2011 Link to this post

    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 >>

  8. Shiva
    Shiva avatar
    61 posts
    Member since:
    Oct 2010

    Posted 23 Aug 2011 Link to this post

    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
  9. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 23 Aug 2011 Link to this post

    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 >>

  10. Kiti
    Kiti avatar
    9 posts
    Member since:
    Jul 2011

    Posted 23 Dec 2011 Link to this post

    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
  11. Jarred Froman
    Jarred Froman avatar
    57 posts
    Member since:
    Aug 2008

    Posted 02 Mar 2012 Link to this post

    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
  12. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Mar 2012 Link to this post

    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 >>
Back to Top
DevCraft banner