Store and send extra data for a row

Store and send extra data for a row

minifiredragonminifiredragon Posts: 42Questions: 7Answers: 2

When I build my table, I sometimes include extra data like a table ID that is not used in generating the columns. When I send the edit to the server I need that information but the only way I can get it to work is if I put it in a hidden column. Is there a way to this without using extra columns? It makes for having a lot of toggle buttons appear for columnToggle I would like to avoid.

Example:
Data: array:
{
name: "Name",
ID: "12',
home: "Home",
}

Table:
Name, Home

When I edit to the table I want it to send the ID back as well.

Answers

  • colincolin Posts: 8,139Questions: 0Answers: 1,362

    You can use ajax.data to send additional data to the server, that would be the way to go.

    Colin

  • minifiredragonminifiredragon Posts: 42Questions: 7Answers: 2
    edited January 27

    That was not quite the answer I was looking for. But I did find it after some rewording of my searches. Here is that I wanted:

    data: function(d)
    {   
        var table = $j('#tbl').DataTable();
        var stored = table.row( this ).data();
    
        d.extra = {};
        d.extra.itemUPCID = stored.item.upcID;
        d.extra.boxUPCID = stored.box.upcID;
        d.extra.caseUPCID = stored.case.upcID;
    
            return JSON.stringify( d );
    }
    

    Which then sent the additional missing information I needed to my server side update.

    For others searching for the answer, it was linked to fnGetData() which was replaced by .row().data(); No where that I have seen (or maybe misread the docs) does it tell you that this stores ALL the data handed to the row, which includes data not used by the columns.

    Which is useful when using the Editor plugin, because that only send column data and not the full row data.

Sign In or Register to comment.