Assign a value to a field before sending

Assign a value to a field before sending

klermannklermann Posts: 277Questions: 67Answers: 1

Hi, How do I assign a value to a field before sending to the server?

Answers

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    field().val() is the API method to use.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited October 2017

    Where can I use this code snippet with the changes to my field??
    editor .edit( row, false ); .val( 'contaA', 'Conta A' ); .val( 'contaB', 'Conta B' ); .submit();

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    Wherever it is that you want to change the values of those two fields. I would not that you have a syntax error (.val is not valid without editor in front of it). You also need to define what the row variable is.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    Hello, I was able to solve the first problem. Now I just need to retrieve, retrieve, retrieve, the value of "Conta Atual" that comes from the table to be seated in the second select that is with the "Selecione a conta B" placeholder, that when I open the editor it is empty, without the value for to edit!
    ec2-54-157-236-83.compute-1.amazonaws.com:8080/financeiro/transferencias/

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    Same issue as before :). You are using minhasContas[].nome which resolves to "Conta B" for example, but the select list doesn't contain that value:

    It contains ids. minhasContas[].id is what you need, but you already have that. I don't understand why the same field is shown twice?

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1
    edited October 2017

    Allan, are exactly two fields that need transactions, transfers between accounts. Withdraw from one account and transfer to another.
    In the first field I get the value correctly, but in the second no!

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    How are you storing them in the database? Are they in two different columns?

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    In my database I have tranferencias that have the columns contaA and contaB that relates to minhasContas, that has the lines contaA and contaB

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    Okay, so I'm still not understanding I'm afraid. If you have the columns contaA and contaB in the database table, why not set the names for the fields to match that?

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    why do I need the options to be loaded into a list and when I edit it gets the contaA in list 1 and contaB in list 2

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    why do I need the options to be loaded into a list

    I don't know. Why do you?

    If your fields are simply contaA and contaB I would expect the JSON to contain the values for those data points in the database, and also the joined table information for those two fields so you can display them in the table.

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    I did not quite understand his position, and what he meant. I'll explain better. Point 1. The Conta anterior value of the table is already being received and loaded in list 1 (A), in the first list of the editor as you can see in the images. OK. Point 2. The Conta atual value is NOT being received in the editor's list 2 (B) as you can see in the images and url I sent. How do I receive the Conta atual value properly from the table in list 2 (B) of the editor?

This discussion has been closed.