Problem with select row in datatables.net
Problem with select row in datatables.net
thuc207
Posts: 2Questions: 0Answers: 0
I writed script to select row in table, but it doesn't execute.
plz help me.
this is script:
var oTable;
var gaiSelected = [];
$(document).ready(function () {
$('#form').submit( function() {
alert (gaiSelected);
return false;
} );
oTable = $('#sampleTable').dataTable({
"oLanguage": {
"sZeroRecords": "No records to display",
"sSearch": "Search on UserName"
},
"aLengthMenu": [[10, 25, 50, 100, 150, 250, 500, -1], [10, 25, 50, 100, 150, 250, 500, "All"]],
"iDisplayLength": 10,
"bSortClasses": false,
"bStateSave": false,
"bPaginate": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bDeferRender": true,
"sAjaxSource": "Service/AdminCustomer.asmx/GetItems",
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
if (jQuery.inArray(aData[0], gaiSelected) != -1) {
(jQuery)(nRow).addClass('selected');
}
return nRow;
},
"aColumns": [
{ "mData": "iusid" },
{ "mData": "vusername" },
{ "mData": "vpassword" },
{ "mData": "vcusname" },
{ "mData": "dbirthday" },
{ "mData": "vprovince" },
{ "mData": "vaddress" },
{ "mData": "vphone" },
{ "mData": "vmobile" },
{ "mData": "vemail" },
{
"mData": null,
"sClass": "center",
"sDefaultContent": 'Edit /'
}
],
"fnServerParams": function (aoData) {
aoData.push({ "name": "iParticipant", "value": $("#participant").val() });
},
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success":
function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
$("#sampleTable").show();
}
});
}
});
(jQuery)('#sampleTable tbody tr').live('click', function () {
var aData = oTable.fnGetData(this);
var iId = aData[0];
if (jQuery.inArray(iId, gaiSelected) == -1) {
gaiSelected[gaiSelected.length++] = iId;
}
else {
gaiSelected = jQuery.grep(gaiSelected, function (value) {
return value != iId;
});
}
$(this).toggleClass('selected');
});
});
plz help me.
this is script:
var oTable;
var gaiSelected = [];
$(document).ready(function () {
$('#form').submit( function() {
alert (gaiSelected);
return false;
} );
oTable = $('#sampleTable').dataTable({
"oLanguage": {
"sZeroRecords": "No records to display",
"sSearch": "Search on UserName"
},
"aLengthMenu": [[10, 25, 50, 100, 150, 250, 500, -1], [10, 25, 50, 100, 150, 250, 500, "All"]],
"iDisplayLength": 10,
"bSortClasses": false,
"bStateSave": false,
"bPaginate": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bDeferRender": true,
"sAjaxSource": "Service/AdminCustomer.asmx/GetItems",
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
if (jQuery.inArray(aData[0], gaiSelected) != -1) {
(jQuery)(nRow).addClass('selected');
}
return nRow;
},
"aColumns": [
{ "mData": "iusid" },
{ "mData": "vusername" },
{ "mData": "vpassword" },
{ "mData": "vcusname" },
{ "mData": "dbirthday" },
{ "mData": "vprovince" },
{ "mData": "vaddress" },
{ "mData": "vphone" },
{ "mData": "vmobile" },
{ "mData": "vemail" },
{
"mData": null,
"sClass": "center",
"sDefaultContent": 'Edit /'
}
],
"fnServerParams": function (aoData) {
aoData.push({ "name": "iParticipant", "value": $("#participant").val() });
},
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success":
function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
$("#sampleTable").show();
}
});
}
});
(jQuery)('#sampleTable tbody tr').live('click', function () {
var aData = oTable.fnGetData(this);
var iId = aData[0];
if (jQuery.inArray(iId, gaiSelected) == -1) {
gaiSelected[gaiSelected.length++] = iId;
}
else {
gaiSelected = jQuery.grep(gaiSelected, function (value) {
return value != iId;
});
}
$(this).toggleClass('selected');
});
});
This discussion has been closed.