colorpicker customcolors via json

Hi,

I have a colorpicker as part of a form I am loading via json, but wanted to have the customColors enabled. How would I do that? I have tried:

{
“type”: “colorpicker”,
“name”: “someColor”,
“label”: “Color:”,
“value”: “#452342”,
“offsetLeft”: “10”,
“labelWidth”: “45”,
“imagePath”: “/codebase/imgs/”,
“customColors”: “1”
}

as well as some other variances to no avail.

Cheers,

Alex

Hi
There is no such attribute as customColors:
docs.dhtmlx.com/doku.php?id=dhtm … olorpicker

But you can get colorpicker object from the form:
var dhxColorPicker = myForm.getColorPicker(“myPicker”);
And set this property to it via script:
dhxColorPicker.setCustomColors(colors)

Darya,

Thanks for the idea. The attribute shown when creating as an html input element:

This example is located at:

docs.dhtmlx.com/doku.php?id=dhtm … olorpicker

under

Input-Based Initialization

These controls are really great. Their approach is different (and more powerful as a result). I find it difficult to get my head completely around them due to documentation issues.

Cheers,

Alex

Hi again :slight_smile:
We will add support in future version
For existing form you can add the following changes:

  1. dhtmlxform_item_colorpicker.js line ~ 35
    this.colorpicker[item._idd] = new dhtmlXColorPicker(this.cz[item._idd], null, null, true);
    chaneg with:
    this.colorpicker[item._idd] = new dhtmlXColorPicker(this.cz[item._idd], null, item.getForm()._s2b(data.enableCustomColors), true);
  2. to enable:
    {type: “colorpicker”, …, enableCustomColors: “1”}
  3. dhtmlxform_item_colorpicker.js line ~ 39 (after this.colorpicker[item._idd].init(); ), add:
    if (typeof(data.customColors) != “undefined”) this.colorpicker[item._idd].setCustomColors(data.customColors);
  4. {type: "colorpicker", ..., enableCustomColors: "1", customColors: "#a4bed4,#c0c0c0"}

Summary:

this.colorpicker[item._idd] = new dhtmlXColorPicker(this.cz[item._idd], null, item.getForm()._s2b(data.enableCustomColors), true); ... if (typeof(data.customColors) != "undefined") this.colorpicker[item._idd].setCustomColors(data.customColors);

Darya,

That is exactly what I needed.

Cheers,

Alex

You are welcome!