Change the parameter key

Change the parameter key

sandberg75sandberg75 Posts: 1Questions: 1Answers: 0

Hi,
I have been using DataTables for a while (love it) and just started to work with Editor.
Im using a java framework called Stripes that binds parameters to the action bean, on the server side.
When I edit a row the parameters are sent like, key="data[firstname]", value="John".
Is it possible to specify/change the key?

I would like to get rid of the "data[ ]" part so that the value is automatically bound to my javavariable called "firstname", is that somehow possible?

Answers

  • allanallan Posts: 63,364Questions: 1Answers: 10,449 Site admin

    Hi,

    We discussed this by e-mail, but I'll post my reply here as well incase anyone else interested finds this post.

    To remove the data[] part what you can do is make use of the ajax.data option of Editor which allows you to modify the data submitted to the server.

    For example you might have:

    ajax: {
        url: '...',
        data: function ( d ) {
            $.extend( d, d.data );
            delete d.data;
        }
    }
    

    So what the function does is basically "flatten" the object. $.extend() is used to copy all the properties up to the top level and then the data object is simply deleted.

    Regards,
    Allan

This discussion has been closed.