Error in select2 update row in Datatable

Error in select2 update row in Datatable

klermannklermann Posts: 274Questions: 67Answers: 1
edited October 2019 in Free community support

Hello, I am having an error in select2 in the Datatable Editor while trying to update the line in Datatable. Here are images of where I click to update the Datatable Editor line and modal displaying the errors in select2, and also follow the codes of a select2 Datatable Editor for your enjoyment.

It this code:

{
    name: 'tipoDespesas[].id',
    type: "select2",
    opts: {
        language: 'pt-BR',
        tags: true,
        placeholder: "Selecione uma categoria",
        allowClear: true,
        ajax: {
            url: '/financeiro/tipoDespesas/listJson',
            delay: 300,
            processResults: function(obj) {

                var listTR = new Array()

                obj.data.forEach(function(dataTR, i) {
                    listTR[i] = {
                        "text": dataTR.nomeTipoDespesas,
                        "id": dataTR.id
                    };
                });
                return {
                    results: listTR
                };
            },
            data: function(params) {

                var queryParameters = {
                    param: params.term
                }
                return queryParameters;
            },
        },
        createTag: createTag,
        insertTag: insertTag,
        templateResult: templateResult,
        templateSelection: templateSelectionCategorias,
    }
},

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • klermannklermann Posts: 274Questions: 67Answers: 1

    help me!

  • allanallan Posts: 51,736Questions: 1Answers: 7,825 Site admin

    Hi,

    Can you link to a page showing the error so I can help to debug it please?

    Thanks,
    Allan

  • klermannklermann Posts: 274Questions: 67Answers: 1

    Hi, follow - >
    nome(user): datatable@datatable.com
    senha(pass): datatable

    191.209.32.171:888/financeiro/despesas/

  • allanallan Posts: 51,736Questions: 1Answers: 7,825 Site admin

    Thanks for the link. However, I'm afraid its timing out for me at the moment.

    Allan

  • klermannklermann Posts: 274Questions: 67Answers: 1
  • allanallan Posts: 51,736Questions: 1Answers: 7,825 Site admin

    It looks like:

                data: function(params) {
     
                    var queryParameters = {
                        param: params.term
                    }
                    return queryParameters;
                },
    

    Is interfering with the data object that Editor is sending to the server. The Select2 plug-in should be sending an initialValue boolean and value properties when the form is placed into edit mode. The server is then expected to return with the required JSON for that selected value.

    Could you try removing that data function please?

    Allan

  • klermannklermann Posts: 274Questions: 67Answers: 1

    @Allan - I removed the part of the code you asked me for, but the problem persists, as you can check it yourself!

  • klermannklermann Posts: 274Questions: 67Answers: 1
    edited October 2019

    clipboardfinanceiro-env.us-east-1.elasticbeanstalk.com/despesas/
    nome(user): datatable@datatable.com
    senha(pass): datatable

    Hi Allan How can I retrieve the values ​​on click and send them to the servers? Since it looks like you gave up on helping me!

  • allanallan Posts: 51,736Questions: 1Answers: 7,825 Site admin

    Sorry I lost track of this thread. You still have:

                                    data: function (params) { 
                                        
                                        var queryParameters = {
                                            param: params.term
                                        }
                                        return queryParameters;
                                    },
    

    in the select2 fields. Could you remove them please? I'm not seeing any parameters being sent to the server on initial view of the editing panel, and I think that might be the reason.

    Allan

  • klermannklermann Posts: 274Questions: 67Answers: 1

    Allan commented on the part of the code that asked me, and yet the error continues ...

    Look:
    clipboardfinanceiro-env.us-east-1.elasticbeanstalk.com/despesas/
    nome(user): datatable@datatable.com
    senha(pass): datatable

  • klermannklermann Posts: 274Questions: 67Answers: 1

    Hi Allan How can I retrieve the values ​​on click and send them to the servers? Since it looks like you gave up on helping me.

    Allan commented on the part of the code that asked me, and yet the error continues ...

    Look:
    clipboardfinanceiro-env.us-east-1.elasticbeanstalk.com/despesas/
    nome(user): datatable@datatable.com
    senha(pass): datatable

  • allanallan Posts: 51,736Questions: 1Answers: 7,825 Site admin

    Hi,

    Lost track of it again - this forum moves so quickly!

    So with that commented out the Select2 instances make requests such as:

    minhasContas/listJson?initialValue=true&value%5B%5D=2

    i.e.:

    initialValue: true
    value[]: 2
    

    Is your listJson script handling that initialValue request? It looks like it is just returning the data for the table.

    Allan

  • klermannklermann Posts: 274Questions: 67Answers: 1

    I did not understand what you meant. But the point is: in select data update occurs automatically without the page refresh and even to insert a new data the user can! I do not understand how this is affecting the operation of the update. Can't implement a code rollback output to send select data along?

    ´´´
    rowCallback: function ( row, data, action, field ) {

                    var verify = $('.verify', row);
                    $('input.checkbox-default', row).prop( 'checked', data.pagamento == '1' );
                    if(data.pagamento == true){
                        verify.html('<span class="font-size-12 teal-500">Paga!</span>');
                    }else if(data.pagamento == false){
                        verify.html('<span class="font-size-12 red-500">Pendente</span>');
                    }
             },
    

    ´´´

    Thanks!

Sign In or Register to comment.