update row w/ checkbox

update row w/ checkbox

antoniocibantoniocib Posts: 277Questions: 62Answers: 1

Good morning everyone,

I would like to create let's say a rule.

This is the table:

For example the user goes to change the date I want that if the checkbox is validated (so its value is 1) it must return to 0 zero automatically.

It can be done?

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 3,000Questions: 87Answers: 421
    edited May 2022

    First you need to notice whether an Editor value has changed at all. The link below looks like a good solution but I would use "submitSuccess" to determine the new date value instead of "initSubmit" because you never know wether a submission will succeed on "initSubmit".

    https://datatables.net/forums/discussion/49721/trigger-script-if-a-value-has-changed-in-a-field-between-when-editor-being-spawned-to-when-updated

    Once you notice a change you can make an Editor submission or a proprietary ajax call to change the checkbox field value and then ajax reload it.

  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1
    edited May 2022

    @rf1234 can you give me an example with submitSuccess?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You could also use dependent() - like this example here. There, if the office value is changed, the salary is set to $999,999 - you would do something similar with your checkbox.

    Colin

  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1
    edited May 2022

    Okay Colin its great the example but:

    @colin and @rf1234

     {
    label:     "HUB:",
    name:      "salary",
    type:      "checkbox",
                              **  visibility: "false",**
    separator: "|",
    options:   [
    { label: '', value: 1 }
    ]
    }
    

    I need to hidden the fields in modal, i try in this way but not works, how i do?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    With my example, you can just add field().hide() after the field().set(), something like this:

          editor.field('salary').set('$999,999').hide();
    

    Colin

  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1

    Thanks @colin works.

Sign In or Register to comment.