Jeditable support

Jeditable support

JovanJovan Posts: 16Questions: 0Answers: 0
edited September 2010 in General
As you might know, jeditable requires for node to have id attribute set to be same as database column field name. This id is sent as column name so that we know what field we need to update. Also element needs id attribute to be set with database row id value to be sent as database row id to know what row this field belongs to.
So my question is: is there a way to add and id attributes when adding new rows with fnAddData and
when we use ajaxSource and Server Side processing?

Replies

  • luzikluzik Posts: 3Questions: 0Answers: 0
    edited September 2010
    column id propably can be get with sName ..but i'm searching for such solution too
    i found hidden http://datatables.net/examples/server_side/editable.html (look into source) but this example seams to be unfinished :(
  • JovanJovan Posts: 16Questions: 0Answers: 0
    I made my solution, added this code to jeditable.js
    you can put fields as ids of header elements and it will grab them instead.

    [code]
    var submitdata = {};
    submitdata[settings.name] = input.val();
    //submitdata[settings.id] = self.id;

    if (self.id)
    {
    submitdata[settings.id] = self.id
    }
    else
    {
    var i = $(this.parentNode).index( );
    submitdata[settings.id] = $(this.parentNode.parentNode.parentNode.parentNode).children('thead').children('tr').children('th').eq(i).attr('id');
    }
    [/code]

    And for row_id you can put first column to contain db row ids and hide it, in the same way as below take values of first column of selected row, something like this:

    [code]
    $(this.parentNode).children('td').eq(0).attr('id');
    [/code]
  • keturnketurn Posts: 18Questions: 0Answers: 0
    to get the database IDs in the table, I'm using

    [code]fnRowCallback = function (nRow, aData, iDisplayIndex) {
    $(nRow).data('taskID', aData[0]);
    return nRow;
    };
    [/code]

    and I've been using jeditable's "submit to function" and putting together the request myself.
  • JovanJovan Posts: 16Questions: 0Answers: 0
    Your is more elegant solution, could you provide an example how to put together the request?
  • keturnketurn Posts: 18Questions: 0Answers: 0
    It's hard for me to extract to post an example on the forum, because it's wrapped up in a lot of application-specific code, but at its core it uses jQuery.ajax with the value from jeditable passed as 'data'.
This discussion has been closed.