Editor: more time + local editing with custom functions

Editor: more time + local editing with custom functions

rldean1rldean1 Posts: 141Questions: 66Answers: 1

My company has a custom framework, and I won't be able to make AJAX calls. I would like to see some examples of how to capture a change (edit, update, delete), and then I would like to feed that change to our functions that handle CRUD operations. Can you point me to the correct article?

Also: I'm probably going to need more than 15 days to figure out how to work this. How do I get more time before committing to the purchase?

Thanks!

This question has an accepted answers - jump to answer

Answers

  • rldean1rldean1 Posts: 141Questions: 66Answers: 1

    So, I can answer 1/2 of my own question:

    Sounds like DT calls this "local editing". Basically, I think I need to capture CRUD events through the .on('preSubmit' ...) listener, and then call my custom functions that handle server-side communication with the corresponding data object created in the preSubmit listener. Something like below.

    Does that seem right?

    var editor; // use a global for the submit and return data rendering in the examples
    
    editor = new $.fn.dataTable.Editor({
        //ajax: "../php/staff.php",
        table: "#example",
        fields: [{/* labels, names */ }]
    
    });
    
    
    editor.on('preSubmit', function (e, data, action) {
    
        if (action == 'remove') {
            console.log(e)
            console.log(data)
            console.log(action)
    
            //call custom function to delete with {data} obj
    
        }
    
        if (action !== 'remove') {
                
                //handle validation here, if desired
    
                console.log("what will be submitted ==>>");
                console.log(data); //The data object that will be submitted to the server
    
                //call custom function to edit with {data} obj
    
    
            }
    
    });
    
    
  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    There are two approached you can take to your first question:

    1. Use local editing in Editor as you mentioned. That can be useful if you want to queue multiple changes to submit them all at the same time.
    2. Use ajax to define your own Ajax call, or call to whatever storage mechanism you are using. This example shows it being used to make use of localStorage for example.

    My personal preference is option 2 since you can then hook into the standard request / response that Editor expects for validation etc much easier.

    Regarding the trial extension - when the existing 15 day trial runs out you'll get an e-mail saying that it is finished. Just drop me a reply and I'll extend the trial for you.

    Regards,
    Allan

This discussion has been closed.