从客户端获取JQuery Jtable的所有记录

时间:2014-10-10 07:21:36

标签: jquery jquery-jtable

如何从客户端的JQuery JTable获取json格式的所有记录。

我的要求是我有一个项目信息要插入数据库以及与该项目相关的作者列表。我在JQuery Jtable中维护这个列表。

点击保存按钮,我将所有表单信息发送到servlet。我还想要JSON格式的作者列表,以便我可以将它发送到servlet。

是否可能。请参阅下面的JQuery jtable

    $('#AuthorTableContainer').jtable({
        title: 'Authors',
        selecting: true,
        edit: true,
        selecting: true, //Enable selecting
        multiselect: true, //Allow multiple selecting
        selectingCheckboxes: true, //Show checkboxes on first column            
        actions: {
            deleteAction :  function (data) {
                $('#AuthorTableContainer').jtable('deleteRecord', {
                key: data.authorId,
                clientOnly:true
                });
            }},
        fields: {
            authorId: {
                title: 'authorId',
                key:true,
                sorting:true,
                width: '30%'
            },
            Name: {
                title: 'Name',
                width: '30%'
            },
            phone: {
                title: 'phone',
                width: '30%'
            },
            Email: {
                title: 'Email',
                width: '30%'
            }
        }
    });
}
};

我想在客户端获取JSON格式的作者列表

1 个答案:

答案 0 :(得分:0)

我得到了解决方案。 我们可以在jtable中使用addRecord方法添加json对象行。 如下。 http://jtable.org/ApiReference/Methods#met-addRecord