RowReorder + editor don´t send post on drop

RowReorder + editor don´t send post on drop

masmovilmasmovil Posts: 4Questions: 1Answers: 0

Hello

I have tried everything that has occurred to me and read other discursions with the same problem but I do not get that after performing a drag and drop send the post to the server. I try all, its very frustrating :(

If anybody can help me this is my code:

                var editor = new $.fn.dataTable.Editor({
                    ajax: '{{ path("template.record.rel") }}',
                    table: $('#dt_dato_plantilla'),
                    idSrc: "id",
                    fields: [
                        { label: "Descripción", name: "descripcion" },
                        { label: "Orden", name: "orden", message: 'Only drag & drop' }
                    ]
                });

                var dt = $('#dt_dato_plantilla').DataTable({
                    serverSide: false,
                    data: this.config.data,
                    columnDefs: [{
                        orderable: false,
                        targets: [1,2,3]
                    }],
                    rowReorder: {
                        dataSrc: 'orden',
                        editor:  editor,
                        update: true
                    },
                    columns: [
                        { data: "orden", title: 'Orden', width: 20, className: 'reorder' },
                        { data: "descripcion", title: 'Descripción', className: 'editable' },
                        {
                            data: "tipoDato",
                            title: 'Tipo de dato',
                            render: function (data, type, full, meta) {
                                return full.tipoDatoTxt;
                            }
                        },
                        { data: "id", visible: false}
                    ],
                    sDom: "<'dt-toolbar'<'col-sm-4 col-xs-6'B>>tr<'dt-toolbar-footer'>",
                    select: true,
                    buttons: [
                        { extend: "remove", editor: editor, text: '<i class="fa fa-trash-o"></i>' },
                        { extend: "edit", editor: editor, text: '<i class="fa fa-edit"></i>' }
                    ]
                });

                editor.on('postCreate postRemove', function () {
                    dt.ajax.reload(null, false);
                });

                editor.on('initEdit', function () {
                    editor.field('orden').disable();
                });

In the examples and in the documentation seems very simple. What am I missing?

Tanks!

Answers

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin

    Hi,

    I don't immediately see anything wrong with your code there. Could you give me a link to a page showing the issue so I can help to debug it?

    Thanks,
    Allan

  • masmovilmasmovil Posts: 4Questions: 1Answers: 0

    Hi.
    I have exactly the same problem.

    It does not work as in the example. Is there any solution?

    Thank you very much

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin

    Happy to help - please link to a test page showing the issue as I requested above.

    Allan

  • masmovilmasmovil Posts: 4Questions: 1Answers: 0

    Hi Allan:

    Thank you for answering so quickly.

    I have created the following URL where the complete example with jquery, datatables, datatables editor and roereorder would be represented.

    http://test.alozanow.webfactional.com/

    As you can see in the console (in chome in network -> xhr) when the drag and drop is performed in the drop it does not launch the edited configuration in the editor.

    Any help is welcome.

    Tank you very much

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin

    Thank you for this. I'll download the page and put in debug Javascript to try and see what is going wrong.

    Allan

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin

    If you add rowId: 'id' to your DataTables initialisation that should solve it.

    The issue is that the table doesn't currently see the id's (default is DT_RowId being read from the data object), so RowReorder isn't correctly setting the values to be edited. Adding rowId to the initialisation will resolve that.

    Allan

  • masmovilmasmovil Posts: 4Questions: 1Answers: 0

    Hi

    Thank you very much Allan.

    In the documentation is not clear and in the example does not indicate anything about the matter, it is a little dark:

    https://editor.datatables.net/examples/extensions/rowReorder.html

    Thank you for answer so quickly, I appreciate it very much.

    Best regards

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin

    Yes, the example uses the default. I've got a bug filed to improve the documentation in this regard.

    Thanks,
    Allan

This discussion has been closed.