Button to update selected rows

Button to update selected rows

lm0@logic1.com.aulm0@logic1.com.au Posts: 11Questions: 3Answers: 0

I have been wrestling with this one for ages - a button to update selected rows;
I have the following code, unfortunately , just the first records gets updated. (The loop is working as the fnUpdate updates the selected rows)

Any help or suggestions would be really appreciated.

                            $("#button_process").click(function () {
                                table.rows().indexes().each(function (idx) {
                                    var row1a = table.row(idx);
                                    if ($(row1a.node()).hasClass('active')) {

                                        // $('#dataTables-1').dataTable().fnUpdate("PAID_Test", parseInt(idx), 13, false, false);
                                        // $('#dataTables-1').dataTable().fnUpdate("2015-01-01", parseInt(idx), 12, false, false);

                                        editor
                                            .edit(idx, false)
                                            .set('TransactionStatus', "PAID")
                                            .set('PaidDate', '2015-01-01')
                                            .submit();

                                        $(row1a.node()).removeClass('active');
                                    }
                                });
                            });

Answers

  • allanallan Posts: 63,235Questions: 1Answers: 10,417 Site admin

    That looks like it could set up multiple Ajax requests, all occurring at the same time, which new requests being sent before the old ones have been handled.

    Unfortunately Editor is not designed to work that way - each request return needs to be handled before a new one can be fired off. You would need to redo the code to set up a queue that will use the submitComplete event that trigger the next item in the queue.

    Not ideal I know! Editor 1.5 will bring multi-row editing where what you have above will be doable with a single call.

    Allan

This discussion has been closed.