There isn't a plug-in for Editor that is currently available to use with a date picker, however, it is fairly easy to create plug-ins as described in the manual.
You can also allow conditional formatting of the cell for mixed content (i.e. colors or non-color content in the same cell) by using a regex pattern to detect if a color hex is in the cell or not. I modified Greg Brainerd's code snippet above to do this:
columns: [{
/* data option isn't necessary unless your dataset is named "color"
if not, you can remove it */
data: "color",
render: function (data, type, row) {
if (type === 'display' &&
data != null &&
data.match(/#([a-f0-9]{3}){1,2}\b/i)) {
return '<div class="colorSquare" style="background:' + data + ';"></div>';
}
return data;
},
/* className isn't necessary either unless you want
parent-level formatting for the cell's contents */
className: "dt-body-center"
}]
The regex /#([a-f0-9]{3}){1,2}\b/i will detect both the shorthand and longform hexadecimal format (one group of 3 alphanumeric characters or two groups of 3 alphanumeric characters such as #f00 or #ff0000 for red). Any time the cell has a color hex content, it'll format accordingly, otherwise it'll leave it alone.
I just realized that this isn't working on mobile devices, clicking the pulldown in the editor modal does not respond. Spectrum is mobile compatible if you check its website. Does anyone have any insight as to why the DT plugin does not carry the mobile functionality?
I'd be surprised if this was because of Editor or DT, I suspect it's more likely to do with Spectrum. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Answers
Want to understand how to use it.
Hi,
There isn't a plug-in for Editor that is currently available to use with a date picker, however, it is fairly easy to create plug-ins as described in the manual.
Let me know how you get on with it.
Allan
Hey Allan,
I just got spectrum to work as a plug in, http://bgrins.github.io/spectrum/.
Make sure you include the spectrum.css and js.
Then in the editor area script.
Then within the editor configuration
Lastly I used this to display a square color in the regular table itself. You'll need this CSS
In the table columns,
Awesome! Thanks for sharing this with us.
Allan
Cheers Greg.
Really Useful
Greg Brainerd
Thanks, you just spared me a lot of work!
Thats grwat.
Could you please adapt this code for full use of the spectrum, i mean advanced ui
Thank you so much.
You can also allow conditional formatting of the cell for mixed content (i.e. colors or non-color content in the same cell) by using a regex pattern to detect if a color hex is in the cell or not. I modified Greg Brainerd's code snippet above to do this:
The regex /#([a-f0-9]{3}){1,2}\b/i will detect both the shorthand and longform hexadecimal format (one group of 3 alphanumeric characters or two groups of 3 alphanumeric characters such as #f00 or #ff0000 for red). Any time the cell has a color hex content, it'll format accordingly, otherwise it'll leave it alone.
-- Mike
I just realized that this isn't working on mobile devices, clicking the pulldown in the editor modal does not respond. Spectrum is mobile compatible if you check its website. Does anyone have any insight as to why the DT plugin does not carry the mobile functionality?
Hi @piq_pm_pjk ,
I'd be surprised if this was because of Editor or DT, I suspect it's more likely to do with Spectrum. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin