send hidden field value in makeeditable loaddata variable

send hidden field value in makeeditable loaddata variable

j555j555 Posts: 3Questions: 0Answers: 0
edited April 2013 in General
I am a datatables newbie but hope someone can guide me in the right direction.

I am using makeeditable to generate a select box from a php function using loadurl which works just fine. The problem I am having is I need to send the id of the row to the function and I can't seem to figure out how to do it. I can create a static variable in loaddata but I can not set the value of a field to be the row id which is a hidden field in the datatable.

[code]
var exampleTable = $('#example').dataTable().makeEditable({
sUpdateURL: function(value, settings)
{
$.ajax({
type: "POST",
url: "<?php echo site_url('quotes/ajax/edit_datatables');?>",
data: ""
success: function(){
oTable.fnDraw();
}
})
return value;
},

aoColumns: [
{ },
{ event: 'click',
select: 'true'
},
{ },
{ },
{ },
{ event: 'click',
select: 'true'
},
{
onblur: 'submit',
type : "select",
loadurl: "<?php echo site_url('select/ajax/get_select');?>",
loadtype: 'POST',
loaddata: { "id": "2" }, // should be the value of the first datatable column which is a hidden column
//loaddata: { "id": oTable.fnGetData(oTable.fnGetPosition(this)[0])[0].toString() },
event: 'click',
select: 'true'
},
{ event: 'click',
select: 'true'
},
{ },
],
});
[/code]

Thanks in advance for the guidance.

Jon

Replies

  • j555j555 Posts: 3Questions: 0Answers: 0
    I have altered the code a bit and although the alert now returns the item_id for the row, the editable select box is now not appearing, the field just becomes blank. Here is my updated code, I hope someone can let me know what I am doing wrong here.

    [code]
    {

    onblur: 'submit',
    placeholder : "",
    cssclass: 'input-small',
    type : "select",
    loadurl: "<?php echo site_url('select/ajax/get_select');?>",
    loadtype: 'POST',

    loaddata: { "item_id": $('#example').on('click', 'tbody tr', function (e) {
    var item_id = $(this).closest('tr').attr('id');
    alert($(this).closest('tr').attr('id'));
    return item_id;
    })
    },

    width: '100%',
    event: 'click',
    select: 'true'


    },
    [/code]

    I am new to jquery so please be nice when you tell me why this won't work and what I should be doing instead :)

    Thanks for the help,

    Jon
This discussion has been closed.