3

我正在开发和使用 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

4

1 回答 1

2

使用 'rowInserted' 事件并检查您的数据记录(例如在您的字段定义之后):

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

于 2014-01-10T09:38:49.730 回答