How to submit more than one value when using the jeditable datatable ?
How to submit more than one value when using the jeditable datatable ?
burningflames
Posts: 9Questions: 0Answers: 0
Hi ,
When we change the value of a cell, only the value is sent as POST parameter. But this is not enough to update the value in the table ( Don't we need to use the update query using the WHERE clause ??)
So I need to pass more than one value as the POST parameter, preferably the whole row. How can one do this ?
Is there any other neater way to achieve updation ?
I am completely new to jquery and DataTable, any help in this regard will be highly appreciated.
Thanks a lot
When we change the value of a cell, only the value is sent as POST parameter. But this is not enough to update the value in the table ( Don't we need to use the update query using the WHERE clause ??)
So I need to pass more than one value as the POST parameter, preferably the whole row. How can one do this ?
Is there any other neater way to achieve updation ?
I am completely new to jquery and DataTable, any help in this regard will be highly appreciated.
Thanks a lot
This discussion has been closed.
Replies
I think this is probably more of a question for the jEditable authors, but looking at the source code, it would appear that you can pass it the parameter "submitdata" for "Extra parameters to send when submitting edited content". I presume that this can be edited on-the-fly by modifying the jEditable settings, particularly in a function which is called prior to submitting the data ("onsubmit").
Hope this helps - if you need for information - give me a shout!
Allan
I now understand that there is an option to send extra parameters when submitting edited content.
This leads me to another question ( I am a noob, please excuse )
How do I extract the other values from DataTable to send as the extra params ??
Actually, I do not understand what you have done in the following code :( I think this is extracting only the edited cell value. How can I use the single value to update the table? I believe I would need the values of other cells as well. What am I missing ?
$('#example tbody td').editable( 'media/examples_support/editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
}
} );
You are quite correct - my demo only shows a single cell being edited and updated. To get extra information about a particular row, what you can do is make use of fnGetPosition() to get the row index that is currently being edited. From there, you will be able to obtain all the data you need from that row:
[code]
$('#example tbody td').editable( 'media/examples_support/editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"onsubmit": function ( settings, self ) {
var aPos = oTable.fnGetPosition( self );
var aData = oTable.fnSettings().aoData[ aPos[0] ]._aData;
/* do whatever processing you want */
return true;
}
} );
[/code]
Note I haven't actually tested this code, but hopefully you will get the general idea from it.
Regards,
Allan
Thanks.... I will get back to you after I test your code :)
Thanks a LOT
I am sorry. I hope I am not getting onto your nerves, but I am not able to make this work :(
There is a javascript error saying aPos is null.
Can you write the code that will help me submit POST parameters after pulling the values of ALL the fields from DataTable. Please help me through this. This is very important for me.
Thanks a lot for your time and patience.
While I won't directly write the code for you just now, I will note that I made a slightly mistake in the code I originally posted. I've now corrected this and oPos and aData are correctly found. For this you can modify the jEditable settings object as required.
Regards,
Allan
[code]
/* Apply the jEditable handlers to the table */
function Righe_Editabili()
{
$('#data_tbl_progetti_nuovi tbody td:nth-child(4),td:nth-child(5)').editable( 'includes/__ajax_gear/_editable_row_progetti_temp.php', {
"callback": function( sValue, y ) {
var aPos = Table_new_project.fnGetPosition( this );
Table_new_project.fnUpdate( sValue, aPos[0], 0 );
Table_new_project.fnDraw(); // dataTable refresh
//aPos[0] = rows index
//aPos[1] = column ndex
//alert('aPos[0]= '+aPos[0]+' aPos[1]= '+aPos[1]);
},
/*
"submitdata": function ( value, settings ) {
return { "row_id": this.parentNode.getAttribute('id') };
},
*/
/* alternative code for submitdata*/
"submitdata": function ( settings,self ) {
var aPos = Table_new_project.fnGetPosition( this );
var aData = Table_new_project.fnSettings().aoData[aPos[0]]._aData;
/* Link a column to it's correct ID for jeditable! */
if(aPos[1] == 3){
// I called jeditable in 'quantit