我正在开发和使用asp.Net“JTable - JQuery(jtable.org)”。我想仅在字段“Source”的值等于“M”时才显示动作“updateAction”和“DeleteAction”。
<script type="text/javascript">
$(document).ready(function () {
// Define Tooltip temático para a página
$(document).tooltip();
// Configura Jtable Itens 1 com retorno Json através de Page Methods de toda a hierarquia, com 'Lazy Loading':
$('#ItensContainer').jtable({
title: 'Itens',
actions: {
createAction: 'ConItens.aspx/CreateItem',
listAction: 'ConItens.aspx/ListItens',
updateAction: 'ConItens.aspx/EditItem', // if (data.record.Source.toString() == "M")
deleteAction: 'ConItens.aspx/DeleteItem' // if (data.record.Source.toString() == "M")
},
fields: {
CodeItem: {
title: 'Item',
width: '9%',
edit: false,
},
Source: {
title: 'Source',
width: '10%',
create: false,
edit: false
},
LinkDetails: {
title: '',
width: '3%',
display: function (dados) {
var $link = '<a href="ConDetailsItem.aspx?CodeItem=' + dados.record.CodigoItem.toString() + '"><img class="Botoes-lupa-detalhes" src="Content/Images/ico_lupa.gif" border=0 title="Detalhe do item"></a>';
return $link;
},
create: false,
edit: false
}
}
});
}); // End - Document.ready
答案 0 :(得分:2)
使用&#39; rowInserted&#39;事件并检查您的数据记录(例如,在您的字段定义之后):
rowInserted: function (event, data) {
//After child row loads. Check if your info and remove the edit/delete buttons if needed
if (data.record.Source != 'M') {
data.row.find('.jtable-edit-command-button').hide();
data.row.find('.jtable-delete-command-button').hide();
}
}
由jTable的创建者提供的解决方法:https://github.com/hikalkan/jtable/issues/893