Disappear row after edit but the edition is successful datatable editor, suggestions?

Disappear row after edit but the edition is successful datatable editor, suggestions?

Jose Juan HernandezJose Juan Hernandez Posts: 6Questions: 2Answers: 0

Hi, im using datatable editor in mvc .net , when edit a field value the row disappear after sumit. when i catch the result json the edited object is not return but the edition is succesfull.
Help!!

Answers

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

    The problem will be that the JSON isn't being returned. Does the server return an error?

    Colin

  • Jose Juan HernandezJose Juan Hernandez Posts: 6Questions: 2Answers: 0

    Hi Colin, The problem was that my params doesnt updated so I resolved it with editor.ajax()

  • Jose Juan HernandezJose Juan Hernandez Posts: 6Questions: 2Answers: 0

    Now I have a new problem jeje... I have an autocomplete in one of my fields and it doesnt work when i delect an item with de click mouse but if i select with the key and key enter it works normally. do you know some similar case?

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

    Are you able to link to your page so we can take a look?

  • Jose Juan HernandezJose Juan Hernandez Posts: 6Questions: 2Answers: 0

    Actually i am working locally. Here is the editor code that I'm using:

        var editor = new $.fn.dataTable.Editor({
            ajax: UrlTblDetalle,
            table: "#tblDetalles",
            idSrc: 'id',
            fields: [
                        {
                            label: "Descripción:",
                            name: "detalle",
                            def: "GC000"
                        },
                        {
                            label: "Folio:",
                            name: "folioUnicoMantenimientoId",
                            def: $('#FolioId').val()
                        },
                        {
                            label: "Familia:",
                            name: "familiaMantenimientoId",
                            def: 1
                        },
                        {
                            label: "Código:",
                            name: "codigo",
                            type: "autoComplete",
                            opts: {
                                minLength: 3,
                                source: fnCodigosArray(),
                                select: function (event, ui) {
                                    if (ui.item == null || ui.item == undefined) {
                                        GuardarCampos("GN000", "Generico");
                                    } else {
                                        GuardarCampos(ui.item.id, ui.item.text, ui.item.cProm);
                                    }
    
                                    return false;
                                }
                            },
                            def: "GN000"
                        },
                        {
                            label: "Cantidad Promedio:",
                            name: "CantidadPromedio",
                            def: "0"
                        },
                        {
                            label: "Costo Promedio:",
                            name: "CostoPromedio",
                            def: "0"
                        }
            ]
        });
    
    
        function GuardarCampos(Codigo, Detalle, cProm) {
            var modifier = editor.modifier();
            var seleccionado = tblDetalles.row(modifier.parentNode).data().DT_RowId;
            console.log(seleccionado);
            console.log(Codigo);
            console.log(Detalle);
            console.log(cProm);
            editor
            .edit(seleccionado, false)
            .set('codigo', Codigo)
            .set('detalle', Detalle)
            .set('CostoPromedio', cProm)
            .submit();            
        }
    
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    I have an autocomplete in one of my fields and it doesnt work when i delect an item with de click mouse but if i select with the key and key enter it works normally. do you know some similar case?

    I've not hear of this one I'm afraid, so I don't have an immediate answer. That said, are you expecting the GuardarCampos function to be called when you delete with the mouse button? I'm not sure if jQuery UI's AutoComplete will trigger a select action on delete. It might be worth trying a plain jQuery UI AutoComplete input (i.e. not in Editor) and seeing if that is the case.

    Thanks,
    Allan

  • Jose Juan HernandezJose Juan Hernandez Posts: 6Questions: 2Answers: 0

    Thanks Allan!! I was debuggin my code and found that the click on autocomplete is losed by the propagation at events so the datatable take it like the own click on the cell, i put event.stopPropagation() in my select event (autocomplete) but doesnt work and the datatable take it like the own click on the cell.
    I try too with editor.close() after event.stopPropagation() but it doesnt works.
    Do you have any idea?

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Could you check the owns function in your copy of the jQuery UI AutoComplete plug-in for Editor matches this:

        owns: function ( conf, node ) {
            if ( $(node).closest('ul.ui-autocomplete').length ) {
                return true;
            }
            return false;
        },
    

    There was a typo in the selector before and its possible you got copy with that typo.

    If it isn't that, then I'd need a link to a page showing the issue.

    Thanks,
    Allan

This discussion has been closed.