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

Filter Colours

2 Answers 68 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 16 Nov 2009, 03:51 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetie
Telerik team
answered on 19 Nov 2009, 04:27 PM
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.
0
Martin
Top achievements
Rank 1
answered on 23 Nov 2009, 11:04 AM
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
Tags
ColorPicker
Asked by
Martin
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Martin
Top achievements
Rank 1
Share this question
or