Filter Colours

3 posts, 1 answers
  1. Martin
    Martin avatar
    41 posts
    Member since:
    Sep 2013

    Posted 16 Nov 2009 Link to this post

    Hi

    I have an app where I pre-populate a colour picker from a database table of colours on the server side...
    (This picker appears in a radWindow)

    I then have a "Find Colour" option which populates a SECOND colour picker
    again using server side code

    I would like to use client side code to simply search through the FRST colour picker
    and then populate the SECOND picker with the search results.....
    OR
    simply "Filter" the colours in the first picker

    Is this possible?

    I've attached an image to show the two scenarios...


    Any help appreciated

    Regards

    Martin Hoey


  2. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 19 Nov 2009 Link to this post

    Hi Martin Hoey,
    The RadColorPicker control does not offer the functionality you need out of the box. In case you were using a RadColorPicker with ShowIcon=true, you could have used the approach demonstrated in our Shared colors collection between different ColorPickers with ShowIcon set to "true" knowledge base article.

    In your case however, you use a RadColorPicker that creates its HTML on the server and does not keep its items collection in its client state. For your particular case (RadColorPicker with items that you define yourself in the Items collection, ShowEmptyColor="false", PreviewColor="false", Preset="None" and PaletteModes="WebPalette"), you can use the following approach:
    1. First you need to pass the information about the colors in the Items collection of your source RadColorPicker in some form to the client - you can use a HiddenField for that.
    2. When you filter the colors from the source RadColorPicker, you should first detach some of the handlers that the second RadColorPicker has attached, dispose its HTML and then recreate it with the new items collection. You need not do all this yourself - you can use some of the internal methods of the RadColorPicker for this.
    I have attached a simple test page that demonstrates how you can get the colors from one RadColorPicker, filter them and then set the result collection as items for the second RadColorPicker.

    Please note that this approach uses internal methods of the RadColorPicker and tries to "trick" the control so it might have side effects and in case your RadColorPicker configuration is different than the above described one, it might not work.

    Best wishes,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Martin
    Martin avatar
    41 posts
    Member since:
    Sep 2013

    Posted 23 Nov 2009 Link to this post

    Hi Tsvetie

    Sorry for the delay in my response and Thank You for your solution...

    I will use the Javascript example you proposed, this will make my Find option much slicker!

    Thanks Again

    Martin
Back to Top