theoreticsinc / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Posting additional parameters to server via data on edit #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I know how to push additional server data e.g. table name, to main datatable 
but not to datatables-editable e.g.:

myTable = $('.dataTable').dataTable({
<snip>
 var mytt= <?= json_encode($Tablename); ?>;

<snip>

"sAjaxSource": "server_processing.php",
// pass add. parameter to ajax
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source, and send as 'POST' */
aoData.push( { "name": "Tablename", "value": mytt } );
      $.getJSON( sSource, aoData, function (json) { 
        fnCallback(json)
      });
      }, 

<snip>

How to push the mytt value so that the editing and adding row functions get it?

FYIW, the .editable plugin (another) supports the additional data via:

function make_jeditable () {  
  $(".editable-textarea-auto").editable(myJeditableFunction, {
  <snip>

function myJeditableFunction (value, settings) {
  var edits = new Object();
  var origvalue = this.revert;
  var textbox = this; 
  var result = value;
  if(origvalue == value) {
      this.reset()
      return
  }
  edits[settings.name] = [value];
  myvalue = [value];

   var data_array = this.id.split(".");

 var mytt= <?= json_encode($Tablename); ?>;

  var returned = $.ajax({
    url: 'UpdateData3.php',
    type: "POST", 
    data : {'id': data_array[0],'value': myvalue,  'columnName': 'details', 'Tablename': mytt},

<snip>

Thanks.

Original issue reported on code.google.com by yfn...@gmail.com on 22 Sep 2011 at 4:01

GoogleCodeExporter commented 8 years ago
See 
http://jquery-datatables-editable.googlecode.com/svn/trunk/inline-edit-parameter
s.html.

Original comment by joc...@gmail.com on 22 Sep 2011 at 10:37

GoogleCodeExporter commented 8 years ago
I didn't see it in the version downloaded from the twiki site (1.3?). Besides, 
oUpdateParameters, what's the equivalent for add? oAddParameters?

Thanks

Original comment by yfn...@gmail.com on 23 Sep 2011 at 1:27

GoogleCodeExporter commented 8 years ago
OK, I saw oUpateParameters in the latest  
Can you add similar parameters for Add? e.g. 0AddParameters ?    

Thanks         

Original comment by yfn...@gmail.com on 23 Sep 2011 at 2:40

GoogleCodeExporter commented 8 years ago
No. If you need additional parameters for add request, you can put extra hidden 
fieds in the popup form and they will be posted to the server.

Jovan

Original comment by joc...@gmail.com on 23 Sep 2011 at 5:43

GoogleCodeExporter commented 8 years ago
OK, that'll work. I saw some funny effects though with the latest trunk. I'll 
open up separate issues for them.

Original comment by yfn...@gmail.com on 23 Sep 2011 at 8:07

GoogleCodeExporter commented 8 years ago
I followed your suggestions for oUpateParameters and it worked except that the 
update
is not immediately reflected in the table (it did update the sql OK). I tried 

 fnOnEdited: function(status)
                {   
            myTable.fnDraw();
                },   

(also tried with fnOnEditing)
but it didn't work. How do I force a redraw of the newly edited table? This 
situation is needed because I have opened 2 tabs with similar code but 
different GET eg. 
tab1: dotable.php?play
tab2: dotable.php?work

Sequence: do something in work. Switch to play.
Do inline edits in play, the new edits are not automatically refreshed in play 
(they show work's table instead).

Thanks

Original comment by yfn...@gmail.com on 23 Sep 2011 at 8:23

GoogleCodeExporter commented 8 years ago
Hi,

Do you have any erro in the console or erro in the ajax call (NET panel of 
firebug). JEditable plugin normally updates the cell if there are not errors so 
I do not have control over this. However it worked fine in my example.

Jovan

Original comment by joc...@gmail.com on 24 Sep 2011 at 9:46

GoogleCodeExporter commented 8 years ago
Hi,

I will close this issue because first problem with additional params is fixed. 
Regarding the issue with server not updated could you add a comment and some 
example in the issue 41. Tere is a similar problem reported earlier but I cold 
not reproduce it. It would be helpfull if yo could put yor example online so I 
can try it.

Thanks,
Jovan

Original comment by joc...@gmail.com on 25 Sep 2011 at 6:18

GoogleCodeExporter commented 8 years ago
Regarding the issue with server not updated, I think it's resolved (didn't see 
it later) with the gets instead of getting the table via session cookie. 
Thanks,
Francis

Original comment by yfn...@gmail.com on 29 Sep 2011 at 9:01