3

我正在使用 JQuery jTable 插件来显示我的表记录。

$(document).ready(function () {

        //Prepare jTable
        $('#PeopleTableContainer').jtable({
            title: 'Table of people',
            paging: true,
            pageSize: 2,
            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%'
                },
                RecordDate: {
                    title: 'Record date',
                    width: '30%',
                    type: 'date',
                    create: false,
                    edit: false
                },
                Photo: {
                    title: 'Photo',
                    width: '50%',
                    type: 'img',
                    create: false,
                    edit: false
                }
            }
        });

        //Load person list from server
        $('#PeopleTableContainer').jtable('load');

    });

如您所见,最后一列是Photo. 我已将照片路径存储在 mysql 表的相应表中。我想在最后一列显示图像。这可以使用这个插件吗?我正在用 PHP 开发它。

谢谢。

4

1 回答 1

6

This Should Solve Your Problem:

Photo: {
          title: "Photo",
          width: '50%',
          edit: false,
          create: false,
          display: function (data) {
                return '<img src=' + data.record.ImageURL + ' />';
           }
 }
于 2013-09-05T18:50:11.957 回答