【问题标题】:Is it possible to override UpdateAction in jquery jtable?是否可以在 jquery jtable 中覆盖 UpdateAction?
【发布时间】:2016-03-10 06:24:15
【问题描述】:

我正在使用jquery jtable 在表中填充一些数据。我想覆盖其中的updateAction。我想在updateAction popup 中添加更多字段。甚至可能吗?如果是,我该如何实现?

<script type="text/javascript">
    $(document).ready(function() {
        $('#TableContainer').jtable({
            title : 'User List',
            actions : {
                listAction : 'Controller?action=list',
                updateAction: 'Controller?action=update',
                deleteAction: 'Controller?action=delete' 
            },
            fields : {
                num : {
                    title : 'No',
                    width : '30%',
                    key : true,
                    list : true,
                    create : true
                },
                psid : {
                    title : 'Id',
                    width : '30%',
                    edit : false
                },
                roles : {
                    title : 'Roles',
                    width : '30%',
                    edit : true

                    // options: 'Controller?action=list' 
                   /* options:["jj","kk"] */

                },
                country : {
                    title : 'Country',
                    width : '20%',
                    edit : true
                },
                /* CustomAction: {
                    title: '',
                    width: '1%',
                    sorting: false,
                    create: false,
                    edit: false,
                    list: true,
                    display: function (data) {
                        if (data.record) {
                            return '<button title="Edit Record" class="jtable-command-button jtable-edit-command-button" onclick="alert(' + data.record.TicketId + '); return false;"><span>Edit Record</span></button>';
                        }
                    }
                },
                 */
                recordsLoaded: function(event, data) {
                    $('.jtable-data-row').click(function() {
                        var row_id = $(this).attr('data-record-key');
                        alert('clicked row with id '+row_id);
                    });
                }
            }
        });
        $('#TableContainer').jtable('load');
    });
</script>

我想从下拉列表中的 json 动态添加值。有什么办法吗?

【问题讨论】:

    标签: jquery jsp jquery-jtable


    【解决方案1】:

    您是否尝试过为该字段使用选项edit:true?如果您只想在编辑表单时显示几个字段。但是您已经在表格中添加了这些字段。

    例如,

    TicketId : {
        title: 'Ticket ID',
        width: '15%',
        list : false,
        create: false,        //Make it false when create
        edit: true
    }
    

    希望这会有所帮助。

    【讨论】:

    • 谢谢。我会试试的。你能推荐一些在下拉列表中动态添加值的东西,而不是像“options: ['2', '3']”这样的东西
    • 我不明白,如果您添加值,您将如何取回选定的选项?
    • 我需要将选择的选项发送到服务器。那么,是不是不能在下拉框中动态添加值呢?
    • 我的意思是你在 jsp 中以String[] 进行迭代会更舒服。如果你不介意,为什么要添加下拉值?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-16
    • 2017-03-11
    • 2011-01-03
    • 1970-01-01
    • 2017-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多