Editable datatable not triggering blur event on changing value to other value after first update

Editable datatable not triggering blur event on changing value to other value after first update

measim0089measim0089 Posts: 5Questions: 1Answers: 0

I've a editable data table configured to submit on blur. This works perfectly for any data except the original value for cell.
I'm using the onPreSubmit event and to do other calculation and canceling the submit.For actual submit to server I've separate button for it.

Example:
Suppose I've a cell in a table that has a value 9. Everything works fine when I set value 10. But after setting this value to 10 or any other value it does not let me set back to 9.

Has anyone faced the same issue?

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,993Questions: 87Answers: 421

    No! ... and without your code I am afraid it will be difficult to help ...

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

    Is this using Editor? If so, as you can see here, that doesn't happen normally? Have you checked the browser's console for errors? Or the server?

    Colin

  • measim0089measim0089 Posts: 5Questions: 1Answers: 0
    edited January 2020

    Yes, this is using editor with following setting!

    var editor = new $.fn.dataTable.Editor({
        ajax: $table.data('editUrl'),
        table: '#myTable’,
        fields:myFieldArray,
        formOptions: {
            inline: {
                onBlur: 'submit'
            }
        }
    });
    

    I don't see any error in browser console.
    I'm using the onPreSubmit event for calculation anc cancel submission at last .No submission until separate button is clicked to submit. The example linked seems its actually saving data after every blur event.

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

  • measim0089measim0089 Posts: 5Questions: 1Answers: 0

    To me it seems like blur event does not gets triggered when value is set to original value. I'm quiet new to datatables. Can anybody please point me if there is somewhere I can look at to verify it?

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

    That's correct. The blur is only called if the data has changed, otherwise it wouldn't need to be sent to the server as there's nothing to update. If you need to trigger something when the blur happens, you can use preClose or closed instead.

    Colin

  • measim0089measim0089 Posts: 5Questions: 1Answers: 0

    Actually, I need to trigger blur event on every focus out. Is there something I can use?

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

    You can force a submission, with submit: 'all' in the form-options, giving you something like:

    var editor = new $.fn.dataTable.Editor({
        ajax: $table.data('editUrl'),
        table: '#myTable’,
        fields:myFieldArray,
        formOptions: {
            inline: {
                onBlur: 'submit',
                submit: 'all'
            }
        }
    });
    

    Colin

  • measim0089measim0089 Posts: 5Questions: 1Answers: 0

    Thanks colin. This setup worked for me.

This discussion has been closed.