jEditable/Column name

jEditable/Column name

daveo91daveo91 Posts: 1Questions: 1Answers: 0

Hello, I am trying to use jEditable with data tables. Basically when you edit the field it needs to send the value to my PHP script (which it does) and the id field needs to read the columns heading followed by the row ID.

So js<td id="name|123">Testing</td> would submit as js{ID => 'name|123", Value => 'Testing'}

I am using the fnDrawCallback function and applying an ID to each column using: $('#sortable_table tbody td').attr('id', 'a'); but obviously this just applies an ID of a to each cell. Is there a way to have this apply the ID in the way I want?

If it helps the first column will always be the name, the second column will always be the description and so on for the 10 columns.

The numeric part of the ID field is currently the unique index of the database column the row was fetched from, I have managed to have this stored as the ID on the <tr> tag.

This is the code I currently have, as well as all the commented out attempts of what I have tried to achieve this:

$('#sortable_table').dataTable({
                "bProcessing"    : true,
                "bServerSide"    : true,
                "ajax"            : "<?php echo CURRENT_URL; ?>includes/ajax/supplier_products_list.php",
                "fnDrawCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
                {
                    $('#sortable_table tbody td').editable( '<?php echo CURRENT_URL; ?>includes/ajax/supplier_save.php',
                    {
                        
                        cancel        : 'Cancel',
                        submit        : 'OK',
                        indicator     : '<img src="<?php echo CURRENT_URL; ?>images/loading.gif">',
                        "callback": function( sValue, y ) {
                            oTable.fnDraw();
                        },
                        "height": "14px"
                    });
                    //alert(fnGetData(this));
                    //alert(
                    //alert(nRow.aoData[0]);
                    //alert(JSON.stringify(nRow.aoData[0]._aData[0], null, 4));
                    //var parsed = JSON.stringify(nRow.aoData, null, 4);
                    //alert(parsed);
                    //alert(nRow.nTr);
                    //alert(parsed['nTr']['DT_RowIndex']);
                    $('#sortable_table tbody td').attr('id', 'a');
                }
            });

The data is being brought in through server side includes, so I am not entirely sure how I can make this in to a JS Fiddle? I am sure I am missing something really obvious here so appreciate any feedback.

This discussion has been closed.