init_table: function (data) {
var that = this;
table=$('#datatable').DataTable({
info: false,
paging: false,
data:data,
searching: false,
ordering: false,
columns: [
{
"data": "statusName", render: function (data, type, row) {
var color = '';
if (row.status == 0) {
color = '#0099CC';
}
if (row.status == 1) {
color = '#FF6600';
}
if (row.status == 2) {
color = '#666666';
}
return '<span style="color:' + color + '">' + data + '</span>';
}
},
{ "data": "typeName" },
{ "data": "desc" },
{
"data": "findTime", render: function (data, type, row) {
return moment(data).format('YYYY-MM-DD');
}
},
{ "data": "happenProbabilityName" },
{ "data": "influenceRangeName" },
{ "data": "level" },
{ "data": "strategyName" },
{ "data": "measures" },
{ "data": "responsibleUserName" },
{
"data": "status", render: function (data, type, row) {
var html = '<div><span class="update" style="color:#0099CC;cursor:pointer">更新状态</span></div>';
html = html + '<div><span class="czjl" style="color:#CC9900;cursor:pointer">操作记录</span></div>';
return html;
}
}
],
language: {
"url": "/Content/i18n/datatables.lang.json"
}
});
$('#datatable tbody').on('click', '.update', function () {
var data = table.row($(this).parents('tr')).data();
$('#update').modal('show');
that.rowStatus = data.status;
that.riskId = data.id;
});
$('#datatable tbody').on('click', '.czjl', function () {
var data = table.row($(this).parents('tr')).data();
$('#czjl').modal('show');
that.riskId = data.id;
that.loadRiskTrackList();
});
},
$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "data/arrays.txt",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Click!</button>"
} ]
} );
$('#example tbody').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
alert( data[0] +"'s salary is: "+ data[ 5 ] );
} );
} );
public class DatatablesRequest
{
public int Draw { get; set; }
public int Start { get; set; }
public int Length { get; set; }
public Search Search { get; set; }
public IEnumerable<Order> Order { get; set; }
public IEnumerable<Column> Columns { get; set; }
}
return new DataTablesResponse
{
Data = list,
Draw = datatableRequest.Draw,
RecordsFiltered = list.First().TotalCount,
RecordsTotal = list.First().TotalCount,
Code = EnumErrorCode.OK
};