我使用jTable插件在MVC应用程序中显示数据。我已经设置了如下表格。
$(document).ready(function () {
$('#StudentTableContainer').jtable({
title: 'The Employee List',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'Name ASC', //Set default sorting
actions: {
listAction: '/Employee/Employees',
deleteAction: '/Employee/Delete',
updateAction: '/Employee/Edit',
createAction: '/Employee/Create'
},
fields: {
Id: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Name',
width: '15%'
},
Age: {
title: 'Age',
width: '5%'
},
Position: {
title: 'Post',
options: 'Employee/GetJobPosts',
width: '12%'
},
DownloadUrls: {
title: 'Resume',
width: '13%',
display: function (data) {
if (data.record.DownloadUrls) {
var urls = data.record.DownloadUrls.split(',');
var html = '';
var li = '';
urls.forEach(function (entry) {
li = li + '<li><a href="' + entry + '" target="_blank" runat="server" download>' + entry.split('/').pop() + '</a></li>';
})
html = "<ul>" + li + "</ul>";
return html;
} else {
return 'Please edit and upload resume';
}
},
input: function (data) {
return '<input type="file" name="resume" id="resume" multiple/>'
}
}
},
formCreated: function (event, data) {
console.log('adding multipart attribute')
data.form.attr('enctype', 'multipart/form-data');
}
});
//Load student list from server
$('#StudentTableContainer').jtable('load');
});
其中paging: true,
启用了对jTable的分页,sorting: true,
启用了对jTable的分类。但是正如您可以看到上面的脚本我在1个字段中上传了文件。它显示了记录中上传文件的下载URL。
所以我不希望只在1个字段的DownloadUrls上启用排序。其他字段需要排序
我见过Disable Column Header sorting on a JTable,但我使用的是.NET和jQuery而不是Java和Swing,所以一切都只用脚本管理。