easyui-tabs根据数据库的数据动态生产tab

来源:互联网 发布:逆战淘宝代练1元一把 编辑:程序博客网 时间:2024/06/06 00:10
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript">
var lastyear;
$(function() {
    checkPointTabs();    
    $('#checkPointtbas').tabs( {
        tabPosition : 'left',//实现tab在左边
    });
});
function checkPointTabs(){//搜索数据库中的数据
    $.ajax( {
        type : "post",
        async: true,//异步校驗
        url : "${ctx}/pems/checkpointtabs!geTCheckyear.action",
        dataType : 'json',
        success : function(result) {
            for (i = 0; i < result.length; i++) {
                year = result[i].year;
                addPanel(year);//新建tab
            }
        }});    
}
function addPanel(year) {//新建tab
        $('#checkPointtbas').tabs('add',{    
                            title : year,                    
                            content : '<iframe name="'
                                    + year
                                    + '"src="'
                                    + '${ctx}/pems/checkpoint.action?year='
                                    + year
                                    + '" width="100%" height="100%" frameborder="0" scrolling="auto" ></iframe>'
                        });
        $('#checkPointtbas').tabs('select',0);
}
function addPanelYear(){//新增加年度弹出框
     var addpanelyear_dialog = top.parent.sy.modalDialog({
                 title: "增加年度考点",
                 width: 260,
                 height: 180,
                 modal: true,
                 maximizable: true,                
                 url: '${ctx}/pems/checkpoint-input-year.action',
                 buttons: [{
                     text: '确定',
                     iconCls: 'icon-ok',
                     handler: function () {
                         addpanelyear_dialog.find('iframe').get(0).contentWindow.submitForm('${ctx}/pems/checkpoint-input-year!save.action',addpanelyear_dialog,parent.$);
                         window.location.reload(true);
                     }
                 }, {
                     text: '取消',
                     iconCls: 'icon-cancel',
                     handler: function () {
                         addpanelyear_dialog.dialog('destroy');
                     }
                 }],
                 onClose: function () {
                       addpanelyear_dialog.dialog('destroy');
                 }
                 
                 
             }).dialog('open');
}

</script>

<div id="checkPointtbas" class="easyui-tabs cont_z" fit="true"
    data-options="tools:'#tab-tools'"  style="overflow: hidden;">

</div>
<div id="tab-tools">
    <a href="javascript:void(0)" class="easyui-linkbutton"
        data-options="plain:true,iconCls:'icon-add'" onclick="addPanelYear()">增加新年度考点</a>
</div>

0 0
原创粉丝点击