[英]Add Static Column in jTable Jquery
I want to add a static column with somelink,button for each row in my jTable CRUD Jquery. 我想在我的jTable CRUD Jquery中为每一行添加一个带有somelink的静态列。 I`m using the code they are giving for example from jTable site
我正在使用他们提供的代码,例如来自jTable网站
Here is the code: 这是代码:
<script type="text/javascript">
$(document).ready(function () {
//Prepare jTable
$('#PeopleTableContainer').jtable({
title: 'Table of people',
paging: true,
pageSize: 5,
sorting: true,
defaultSorting: 'Name ASC',
actions: {
listAction: 'PersonActionsPagedSorted.php?action=list',
createAction: 'PersonActionsPagedSorted.php?action=create',
updateAction: 'PersonActionsPagedSorted.php?action=update',
deleteAction: 'PersonActionsPagedSorted.php?action=delete'
},
fields: {
PersonId: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Author Name',
width: '40%'
},
Age: {
title: 'Age',
width: '20%'
},
Watch: {
title: 'Watch',
width: '20%',
display: function (data) {
return '';
},
RecordDate: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
//Load person list from server
$('#PeopleTableContainer').jtable('load');
});
</script>
Focus on Watch field in the display: i want to generate for each row some a href with the id of each row. 关注显示屏中的Watch字段:我想为每一行生成一些带有每行id的href。 how i can pull out the id of each row?
我怎么能拿出每一行的id?
It's pretty easy. 这很容易。 See display ( http://jtable.org/ApiReference#fopt-display ) option.
请参阅display( http://jtable.org/ApiReference#fopt-display )选项。 You can define such a field:
您可以定义这样一个字段:
TestColumn: {
title: 'Test',
display: function (data) {
var $link = $('<a href="...">a link</a>');
$link.click(function(){ /* do something on click */ });
return $link;
}
}
Link: {
title: 'More Info',
display: function (data) {
return '<a href="@Url.Action("Index", "Demo")">More Info</a>';
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.