Customized button to set value on selected cell, color a cell when it contains a value

Customized button to set value on selected cell, color a cell when it contains a value

antho_jardantho_jard Posts: 2Questions: 1Answers: 0

Hello everyone,

I am new here, hope my english is not too bad to explain my problem. :)

I am trying to create a small planning editor by using datatable editor for my company and I think I need some help.
Here what that will look like:

I am currently stuck on 3 points:

1) I would like to get a row selection when I click on the technician name in the first column, in order to edit all fields of the the row with the classic editor ; and I would also like to get the ability to select one cell when I click on it in order to change its value by clicking on one of the customized button (for example here : set the value 'Holidays' in the cell when I click on Holidays or 'Sick leave' when I click on 'sick leave'). I don't know how doing this (setting a value in selected cell) with custom button.

2) My second point is that I would like to color the text in the cell when it contains some values:
For example here, tech_05 goes in Normandy (county 14) on Monday.
I would like here to color the text in the cell in red when the string value contains the string-group '(14)' in its field, color in green when the string contains '(27)', blue when it's '(76)' etc..
I know how to color a row when a column is equal to the exact value set in the condition by using "rowCallBack", but I don't know how I could do this in this case.

3) My last point concerns the field editor window. I would like to get something like this :

In my Postgres Database, I have only one field for "Monday". I don't know if it's possible, but I would like to have two input type for each day with the same data name.
I mean, typically, I would to concatenate the value "(14)" of the input list in the editor field with the text input of monday.
Is it possible to get this kind of thing in the editor window ?

Thank you in advance to any one who may be able to give me some help and ideas to do this.
Sincerely,
A. J.

Replies

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Hi,

    1) This example shows how you can set a specific value for a selected row. In your case it would be adapted slightly to set / unset the holiday flag for the cell (or sick leave, etc).

    2) If you've already got this working for an exact value, then it sounds like you just need to change the condition for when the class should be added / removed. In this case String.prototype.indexOf sounds like the correct method to use. e.g. if (data.indexOf('(14)') !== -1) { /* add red */ } else { /* remove red */ }.

    3) What you are looking for is absolutely possible, but it would require a custom field type plug-in to be written which will control both the select and the input for the field, splitting and combining the value between them as required.

    Allan

This discussion has been closed.