Bug in 1.3 beta 3

Bug in 1.3 beta 3

theg33ktheg33k Posts: 6Questions: 0Answers: 0
edited May 2011 in DataTables 1.8
Dunno if this is supposed to be under 1.8 or "bugs" but here goes...

With 1.8 beta 2 I was able to do something like the following

Here's my table definition
[code]
$('#merchantTableContainer').dataTable( {
'bPaginate': false,
'sScrollY': '150px',
'bFilter': false,
'sPaginationType': 'full_numbers',
'bInfo': false,
'bLengthChange': false,
'bSort': false,
'bAutoWidth': true,
'sAjaxSource': '/pos/rest/merchants/dataTable',
'bProcessing': true,
'bServerSide': true,
'aoColumns' : [{'mDataProp': 'id',
'bSearchable': false,
'bVisible': false},
{'mDataProp': 'displayName'},
{'mDataProp': 'clientId'}
]
} );
jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages = 0;
[/code]

Making my table selectable
[code]
$('#merchantTableContainer tbody').click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');

}
);

/* THIS IS THE PART THAT'S MOST IMPORTANT FOR THIS BUG REPORT */
var selectedRow = $(event.target.parentNode);
selectedRow.addClass('row_selected');
loadMerchant(oTable.fnGetData(event.target.parentNode)[0]);
});
[/code]

loadMerchant method (not all that important)
[code]
function loadMerchant(id)
{
$.ajax({
type: 'GET',
url: '/pos/rest/merchants/'+id,
contentType: 'text/html',
success: function(data, textStatus) {
$('#merchantForm').populate(data);
},
error: function ( XMLHttpRequest, textStatus, errorThrown){
alert('error'+textStatus+'\t'+errorThrown);
}
});
$('#add').attr('disabled', 'disabled');
$('#save').removeAttr('disabled');
}
[/code]

Anyways, "id" is now undefined. With 1.8 beta 2 this script was working fine. with 1.8 beta 3 it now shows the id variable as undefined.

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    I've changed the behaviour of fnGetData slightly in the beta 3 release. It will now give you the original object that you give DataTables, rather than the display array. This seemed a lot more useful to me, since you get everything as you fed it in.

    So in this case you could do:

    [code]
    oTable.fnGetData(event.target.parentNode).id
    [/code]
    which should do the trick nicely.

    Allan
  • theg33ktheg33k Posts: 6Questions: 0Answers: 0
    Awesome, worked like a charm. Thanks again!
This discussion has been closed.