其他分享
首页 > 其他分享> > fastadmin表格导出 图片

fastadmin表格导出 图片

作者:互联网

 // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns:true,
                fixedRightNumber:1,
                search:false,
                searchFormVisible:true,
                showColumns:false,
                exportTypes: ['excel'],
                exportOptions: {
                    ignoreColumn: [0, 'operate'],
                    onBeforeSaveToFile: function(data, fileName, type, charset, encoding, bom){
                        return $.fn.bootstrapTable.defaults.extend.savestatus;
                    },
                    onCellHtmlHyperlink: function($cell, rowIndex, colIndex, href, htmlData)
                    {
                        var html = $.parseHTML(htmlData);
                        var inputidx = 0;
                        var selectidx = 0;
                        var result = '';

                        $.each(html, function () {
                            if ($(this).is("input")) {
                                result += $cell.find('input').eq(inputidx++).val();
                            }
                            else if ($(this).is("select")) {
                                result += $cell.find('select option:selected').eq(selectidx++).text();
                            }
                            else if ($(this).is("img")) {
                                var src = $(this).attr('src');
                                if (src.indexOf('http') === -1) {
                                    $(this).attr('src', window.location.origin + src);
                                }
                                $(this).attr("width", "40").attr("height", "100%").attr('class', '');
                                result += '<div>' + $(this).get(0).outerHTML + '</div>';
                            } else {
                                if (typeof $(this).html() === 'undefined') {
                                    result += $(this).text();
                                }
                                else if (jQuery().bootstrapTable === undefined ||
                                    ($(this).hasClass('filterControl') !== true &&
                                        $cell.parents('.detail-view').length === 0)) {
                                    result += $(this).html();
                                }
                            }
                        });
                        return result;
                    }
                },
                columns: [
                    [
                        {checkbox: true},
                   ]
              ]
    })

标签:src,attr,表格,导出,else,cell,result,fastadmin,var
来源: https://blog.csdn.net/qq_31315703/article/details/121293169