Hidden attributes on Datatables
Hidden attributes on Datatables
charly_spence
Posts: 4Questions: 0Answers: 0
Hello,
I have 2 hidden attributes -"type": "hidden"- in a Editor datatable which I'd like to populate by applying some logic based on the user selection on the rest of the other columns.
Which API, plugin or callback function should I use? to save the hidden attributes into the server when the user either edits or creates a row?
Charles
I have 2 hidden attributes -"type": "hidden"- in a Editor datatable which I'd like to populate by applying some logic based on the user selection on the rest of the other columns.
Which API, plugin or callback function should I use? to save the hidden attributes into the server when the user either edits or creates a row?
Charles
This discussion has been closed.
Replies
Sounds like it is the set API method that you will need, which is documented here: http://editor.datatables.net/api/#set .
Allan
I tried by using 'onSetData', but it only works on the client side, nothing is sent to the database for the hidden column (the other columns update just correct)
Thanks
Anyone that can put you on the right track or provide an example on how to achieve what I'm describing?
I'll invite a beer on that
At what point do you want the values to be set for what you are sending to the server? If you want them read from somewhere when the submission is done, what you could do is use the onPreSubmit event:
[code]
editor.on('onPreSubmit', function ( json ) {
json.data.myProp1 = $('#myVal1').val();
json.data.myProp2 = "hello world";
} );
[/code]
Allan
That made the trick, I used the following approach on the table.test.js:
var editor = new $.fn.dataTable.Editor( {
{
"ajaxUrl": "",
"domTable": "#test",
"fields": [
...
],
"events": {
"onPreSubmit": function (json) {
json.data.test_id = "test@test.com";
}
}
} );
I already honored my commitment under the account from Jose Hurtado.
Regards
Allan