Editing a field programmatically

Editing a field programmatically

GeorgeHelmkeGeorgeHelmke Posts: 44Questions: 16Answers: 0
edited November 2014 in Priority support

This is my feeble attempt at editing a field programmatically:

             editor
                   .create(false)
                   .set('No_', '20100')
                    .submit();

It goes wrong because on that one field is filled in, and all of the other fields are NULL.

I am able to do this:

  $('#MainTable tbody ').on('click', 'button', function (event) {
                var row = $(this).closest("tr").get(0);
                var aData = table.row(row).data();
               aData.No_ = "20100";

But it doesn't get submitted, the new value just shows when I click to edit the field.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,579Questions: 1Answers: 8,533 Site admin

    It goes wrong because on that one field is filled in, and all of the other fields are NULL.

    In which case do you need to set the other field values as well? You can call set() on as many fields as you need.

    Or do you actually want the other fields to be null? If so, what is the error that you get?

    Regards,
    Allan

  • GeorgeHelmkeGeorgeHelmke Posts: 44Questions: 16Answers: 0

    The error I get is at the SQL level - these fields need to be filled in.

    An example would really help, so I could see how it is done and then fit the concepts to my situation.

  • allanallan Posts: 54,579Questions: 1Answers: 8,533 Site admin
    Answer ✓

    Hi,

    To use the set() method to fill in other fields you would simply do:

    editor
          .create(false)
          .set('No_', '20100')
          .set('field2', 'value2')
          .set('field3', 'value3')
           .submit();
    

    Repeating the call to set() as needed (with the field and values changed to suit your needs of course!).

    Allan

  • GeorgeHelmkeGeorgeHelmke Posts: 44Questions: 16Answers: 0

    Even I am smart enough to understand that. Thanks!

This discussion has been closed.