preSubmit data undefined

preSubmit data undefined

FicosFicos Posts: 88Questions: 22Answers: 0

ficos.nl/test/uren2015.html
is the test of this problem.
Using preSubmit:

 editor
        .on('preSubmit',function( e, data, action ){
            if(action=='create'){
                alert(data.rec_omschr);
                data.rec_Persoon='2000';
            }   
        }
        );

data keeps undefined. And I need to change the field rec_Persoon after creating but before submitting
Can you help please?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Hi,

    There is no rec_omschr parameter in the information that DataTables sends to the server. The fields are contained within another object (identified by the primary key value) as described here.

    Your best bet is to use $.each( data.data, function ( value, key ) { ... } ); and loop over the data to be submitted for each row that way.

    Regards,
    Allan

  • FicosFicos Posts: 88Questions: 22Answers: 0

    Hi Allan,
    I thought I understood but this is not working:

    editor
            .on('preSubmit',function( e, d, action ){
                if(action=='create'){
                    d.data["0"].km = parseInt(d.data["0"].eind)-parseInt(d.data["0"].begin);
                    //alert(parseInt(d.data["0"].eind)-parseInt(d.data["0"].begin+" -->km : ".d.data[0].km));
                }   
            }
            );
    

    Any idea why?
    Jan

  • FicosFicos Posts: 88Questions: 22Answers: 0

    Solved.

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    To get the first element in the array you would change this:

    d.data["0"].

    To this:

    d.data[0].

    Removing the quotes to make it an integer.

    Kevin

This discussion has been closed.