Column for deleting records

Column for deleting records

hcavhcav Posts: 4Questions: 0Answers: 0
edited January 2010 in General
I'm using datatables with server-side processing and jeditable. I reserved 1st column to associate each row with a register ID (I tried to use TR ID for that, but I wasn't able to). Now I would like to have a column where I can click to delete the record shown in the row.
Any sugestion? Remebering jeditable is keeping all columns editable.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Does it matter what jEditable is doing with a row if you just want to delete it? If you've got the ID ( http://datatables.net/examples/api/editable.html ) then you can just XHR that to the server and have it delete the row and redraw the table.

    Regards,
    Allan
  • hcavhcav Posts: 4Questions: 0Answers: 0
    When I click on any cell, jEditable let me edit that cell then submit the change to the server.
    How jEditable acts on all columns, how can I have a column not handled by jEditable, so I can click on it when I whish to delete that row?
    The problem is not to submit ID to the server, the problem is how to have an event to handle deleting action with jEditable working?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Have a look at these two threads which discuss this very topic. It's all about the selector :-)

    http://datatables.net/forums/comments.php?DiscussionID=591
    http://datatables.net/forums/comments.php?DiscussionID=529

    Allan
  • hcavhcav Posts: 4Questions: 0Answers: 0
    Thank you for you attention, but those solutions allow me make only one column editable.
    I need exactly the opposite, make all columns editable but one.
    Things would be easier if datatables would have a way to receive columns and rows ID within aadata array.
  • hcavhcav Posts: 4Questions: 0Answers: 0
    I got the solution. All my aditional parameters are defined into attr as follows and I used json_encode to data for callback.

    var attr.Container = 'listagem';
    var attr.EditColumns = [2,3,4];

    var fnDrawCallback = function() {
    for (var i in attr.EditColumns) {
    jQuery('table.'+attr.Container+' tbody tr td:nth-child('+attr.EditColumns[i]+')').editable(attr.urlEdit, {
    "callback": function(sValue,y) {
    var aPos = oTable.fnGetPosition(this);
    eval('var resp = '+sValue);
    if (typeof(resp.column) != 'undefined') {
    for (var i in resp.column)
    oTable.fnUpdate(resp.column[i],aPos[0],i);
    }
    if (typeof(resp.alert) != 'undefined')
    alert(resp.alert);
    },
    "submitdata": function (value,settings) {
    var aPos = oTable.fnGetPosition(this);
    var aData = oTable.fnGetData(aPos[0]);
    return {"id":aData[0],"coluna":aPos[2]};
    }
    });
    }
    }
This discussion has been closed.