子表中的 jTable 动态自定义工具栏项



我有一个jTable,每行都有一个子表。 在子表的工具栏标题上,我添加了一个自定义工具栏项。我想使该工具栏项动态化,如果已经有一些行,我不希望它显示。 我遇到了一个非常相似的查询,用于主工具栏"添加新"按钮,该按钮添加了一个在记录上运行的函数加载:

下面是我的第一次尝试 - 它只是指定子表的主表的字段条目。 但是,".find(....("规范在我的情况下不起作用,因为我的规范是一个自定义工具栏项。 我需要输入什么作为 .find 标准?

谢谢

                Dance: {
                title: '',
                width: '4%',
                sorting: false,
                create: false,
                listClass: 'centreCol',
                display: function(book) {
                    var $img = $('<img src="Images/layers.png" title="Show associated dance entries" />');
                    //Open child table when user clicks the image
                    $img.click(function() {
                        var thisrow = $img.closest('tr'); //Parent row
                        if($('#BookTableContainer').jtable('isChildRowOpen',thisrow)) { // Clicking image a second time closes the child row
                            $('#BookTableContainer').jtable('closeChildRow',thisrow);
                        } else {
                            currentTitleID = book.record.DanceTitleID;
                            $('#BookTableContainer').jtable(
                                'openChildTable',
                                thisrow,
                                {
                                    title: 'Related Dance',
                                    toolbar: {
                                        items: [
                                            {
                                                icon: 'Images/add.png',
                                                text: 'New dance',
                                                tooltip: 'Add dance details',
                                                click: function() { CreateDanceDialog(); }
                                            }
                                        ]
                                    },
                                    actions: {
                                        listAction: 'BookPageData.php?action=listChildDances&DanceTitleID=' + currentTitleID,
//                                      createAction: 'dancesData.php?action=createAssignment',
//                                      deleteAction: 'dancesData.php?action=deleteAssignment'
                                    },
                                    recordsLoaded: function(event, data) {
                                        var rowCount = data.records.length;
                                        if (rowCount>0){
                                            $('#BookTableContainer').find('.jtable-toolbar-item.jtable-toolbar-item-add-record').remove();
                                        }
                                    },
                                    fields: {
                                        DanceID: { key: true, create: false, edit: false, list: false, visibility: 'hidden' },
                                        DanceTitleID: { type: 'hidden', defaultValue: currentTitleID },
                                        ChoreographerID: { title: 'Choreographer', width: '40%', options: function() { return ChoreographerOptions; } },
                                        FormationID: { title: 'Formation', width: '30%', options: function() { return FormationOptions; } },
                                        GenreID: { title: 'Genre', width: '30%', options: function() { return GenreOptions; } }
                                    }
                                },
                                function(data) { data.childTable.jtable('load'); }
                            );
                        }
                    });
                    //Return image to show on the person row
                    return $img;
                }
            },

试试这个

$('#BookTableContainer').find('.jtable-toolbar').remove();

最新更新