步骤 1:创建 Tabs

  1. <div style="margin-bottom:10px">
  2. <a href="#" class="easyui-linkbutton" onclick="addTab('google','http://www.google.com')">google</a>
  3. <a href="#" class="easyui-linkbutton" onclick="addTab('jquery','http://jquery.com/')">jquery</a>
  4. <a href="#" class="easyui-linkbutton" onclick="addTab('easyui','http://jeasyui.com/')">easyui</a>
  5. </div>
  6. <div id="tt" class="easyui-tabs" style="width:400px;height:250px;">
  7. <div title="Home">
  8. </div>
  9. </div>

步骤 2:实现 'addTab' 函数

  1. function addTab(title, url){
  2. if ($('#tt').tabs('exists', title)){
  3. $('#tt').tabs('select', title);
  4. } else {
  5. var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
  6. $('#tt').tabs('add',{
  7. title:title,
  8. content:content,
  9. closable:true
  10. });
  11. }
  12. }

我们使用 'exists' 方法来判断 tab 是否已经存在,如果已存在则激活 tab。如果不存在则调用 'add' 方法来添加一个新的 tab 面板。

例子:

<table id="HazardousId" class="easyui-datagrid" style="width:auto;height:500px;" ></table>

<div id="shHazardous" style="padding:5px;height:auto">
<div>
<span class="other">
废物类别代码: <input class="easyui-textbox HazardousWType" style="width:130px">
</span>
<span class="other">
废物类别名称: <input class="easyui-textbox HazardousWTypeD" style="width:130px">
</span>
<span class="other">
行业来源: <input class="easyui-textbox industrySources" style="width:130px">
</span>
<span class="other">
废物代码: <input class="easyui-textbox HazardousWCode" style="width:130px">
</span>
<span class="other">
危险废物: <input class="easyui-textbox HazardousWDis" style="width:130px">
</span>
<span class="other">
危险特性: <input class="easyui-textbox HazardousWFeatures" style="width:130px">
</span>
<a id="searchbtn" href="#" class="easyui-linkbutton searchbtn" iconcls="icon-search">Search</a>
</div>
<div>

ESc  浮框退出      table 自适应浏览器窗口

$(function () {
document.onkeyup = function (e) {
e = e || window.event;
var code = e.which || e.keyCode;
if (code == 27) {
$('#dlg').dialog('close');
}
}
$(window).resize(function () {
$('#V3CompanyApplyId').datagrid('resize', {
height: ($(window).height())
});
});
});

$(function () {
var tableId = "HazardousId";
var controller = "Hazardous";
var urlGetTbById = "/" + controller + "/GetHazardousWById";
var urlGetTbOption = "/" + controller + "/MeasurementCalculateOption";

//搜索功能string是类型,strWhere是变量,1=1 是常量,这个本身是没有什么意义的,只是为了方便在后面加上if(字段1 !=“”)
//strWhere +=“ and 字段1 = ”;
//if(字段2 !=“”)
//strWhere +=“ and 字段2 = ”;
//......

//如果字段都为空 还有 where 1=1 呢 也不影响查询,如果 只剩下where 不就报错了么..

$('#shHazardous .searchbtn').on('click', function () {
var strWhere = " 1=1 ";
if ($('.other .HazardousWType').val() != "") {
strWhere += "and T.HazardousWType like '%" + $('.other .HazardousWType').val() + "%'";
}
if ($('.other .HazardousWTypeD').val() != "") {
strWhere += "and T.HazardousWTypeD like '%" + $('.other .HazardousWTypeD').val() + "%'";
}
if ($('.other .industrySources').val() != "") {
strWhere += "and T1.industrySources like '%" + $('.other .industrySources').val() + "%'";
}
if ($('.other .HazardousWCode').val() != "") {
strWhere += "and T2.HazardousWCode like '%" + $('.other .HazardousWCode').val() + "%'";
}
if ($('.other .HazardousWDis').val() != "") {
strWhere += "and T2.HazardousWDis like '%" + $('.other .HazardousWDis').val() + "%'";
}
if ($('.other .HazardousWFeatures').val() != "") {
strWhere += "and T2.HazardousWFeatures like '%" + $('.other .HazardousWFeatures').val() + "%'";
}
console.log(strWhere);
$('#' + tableId).datagrid("reload", { strWhere: strWhere, page: 1, rows: 10 });
});

var StorageManager = [
{
type: 1,
key: "HazardousWType",
name: "废物类别代码",
val: "",
dpData: ""
},
{
type: 1,
key: "HazardousWTypeD",
name: "废物列别名称",
val: "",
dpData: ""
},
{
type: 1,
key: "industrySources",
name: "行业来源",
val: "",
},
{
type: 1,
key: "HazardousWCode",
name: "废物代码",
val: "",
},
{
type: 1,
key: "HazardousWDis",
name: "危险废物",
val: "",
},
{
type: 1,
key: "HazardousWFeatures",
name: "危险特性",
val: "",
}];

function UIModifyInit(index, type) {
$.ajax({
url: rootUrl + urlGetTbById,
data: { id: index },
async: false,     //false为同步         默认是true;
type: "POST",
success: function (msg) {
//alert(msg);
//msg = $.parseJSON(msg);
if (msg.success = true) {
console.log(msg);
dataOption.msgToModelCompany($.parseJSON(msg.Memo)[0], StorageManager, 1);
dataOption.createDom(StorageManager, "userInfoSelect", type);

}
else {
// console.log(msg.msg);
}
},
dataType: "json"
});

};
$('#' + tableId).datagrid({
height: 500,
url: rootUrl + '/' + controller + '/GetHazardousW',
method: 'post',
fixColumnSize: true,       // 固定列的尺寸
striped: true,                 // 就把行条纹化。(即奇偶行使用不同背景色)
fitColumns: true,           //自动扩大或缩小列的尺寸以适应表格的宽度并且防止水平滚动。
fit: true,                       //折叠容器的大小将填充父容器   自适应
singleSelect: false,         //设置为 true,则只允许选中一行。
rownumbers: true,          //显示带有行号的列
pagination: true,             //True 就会在 datagrid 的底部显示分页栏
nowrap: false,                 //超出部分换行
pageSize: 20,                   //初始化页码尺寸
pageList: [10, 20, 50, 100, 150, 200],         //初始化页面尺寸的选择列表
showFooter: true,              
pageNumber: 1,           //初始化页码。
toolbar: '#shHazardous',
columns: [[
{ field: 'HazardousWType', title: '废物类别代码', width: '10%', align: 'center', fixed: 'true' },
{ field: 'HazardousWTypeD', title: '废物类别名称', width: '15%', align: 'center', fixed: 'true' },
{ field: 'industrySources', title: '行业来源', width: '15%', align: 'center', fixed: 'true' },
{ field: 'HazardousWCode', title: '废物代码', width: '10%', align: 'center', fixed: 'true' },
{ field: 'HazardousWDis', title: '危险废物', width: '40%', align: 'center', fixed: 'true' },
{ field: 'HazardousWFeatures', title: '危险特性', width: '10%', align: 'center', fixed: 'true' },
//{
// field: 'Id', title: '详细信息', width: '10%', align: 'center',
// formatter: function (value, row, index) {
// var addHtml = '<a class="approveApply ob-details" ob-id=' + row.id + ' style="color:blue">详细信息</a>';
// return addHtml ;
// }
// },
]],
onDblClickRow: function (rowIndex, rowData) {
$('#dlg').dialog('open');
UIModifyInit(rowData.id, 1);
$('.ob-addBtn').remove();
}
});
$('#' + tableId).prev().on("click", ".ob-details", function () {
$('#dlg').dialog('open');
UIModifyInit($(this).attr("ob-id"), 1);
$('.ob-addBtn').remove();
});
});
</script>

easyui 动态添加标签页,总结的更多相关文章

  1. EasyUI创建异步树形菜单和动态添加标签页tab

    创建异步树形菜单 创建树形菜单的ul标签 <ul class="easyui-tree" id="treeMenu"> </ul> 写j ...

  2. ES6面向对象 动态添加标签页

    HTML <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml&quo ...

  3. EasyUI 布局 - 动态添加标签页(Tabs)

    首先导入js <link rel="stylesheet" href="../js/easyui/themes/default/easyui.css"&g ...

  4. 解决EasyUI动态添加标签渲染问题

    以下代码用于Js脚本中: var Work_Content_Back = "<table width='99%' class='table' style='margin-bottom: ...

  5. js 面向对象 动态添加标签

    有点逻辑 上代码 thml布局 点击查看代码 <!DOCTYPE html> <html lang="en"> <head> <meta ...

  6. EasyUI中动态生成标签页

    这是最近学到的内容,当时是有思路但是不知道怎么获取当前的点击对象,就没有实现功能,通过更深入的学习,我知道了不仅仅是Java,Oracle中有一个this,同样的EasyUI中也存在一个this,来获 ...

  7. easyui 动态添加组件 要重新渲染

    做项目时动态添加组件是常有的事,easyui动态添加组件时样式会失效,这是因为这个组件没有经过 easyui的解析器解析, 比如:   <pre name="code" cl ...

  8. jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法

    博客分类: jquery-easyui jQueryAjax框架HTML  现象: AJAX返回的html无法做到自动渲染为EasyUI的样式.比如:class="easyui-layout ...

  9. easyui 动态添加input标签

    动态添加easyui控件<input class=" easyui-textbox" > 这样是无效的,因为easyui没有实时监控,所以必须动态渲染$.parser. ...

随机推荐

  1. 管理weblogic服务的启动和停止

    2012-11-10 12:58 26036人阅读 评论(4) 收藏 举报 分类: WebLogic(10) 版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 介绍 Weblog ...

  2. Go -- 今日头条架构

    夏绪宏,今日头条架构师,专注对高性能大规模 Web 架构,云计算.性能优化.编程语言理论等方向,PHP committer,HHVM 项目贡献者.2009 加入百度,先后从事大规模 IDC 自运维设施 ...

  3. reorder-list——链表、快慢指针、逆转链表、链表合并

    Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do thi ...

  4. Android自己定义View基础篇(三)之SwitchButton开关

    自己定义View基础篇(二) 自己定义View基础篇(一) 自己定义View原理 我在解说之前,先来看看效果图,有图有真相:(转换gif图片效果太差) 那来看看真实图片: 假设你要更改样式,请改动例如 ...

  5. HBase技术简介

    一.HBase简介 HBase – Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群. ...

  6. Vue 基础

    1. data 数据 methods 方法 watch 监听变化 2. 模版指令(类似 angular) {{}} v-text 渲染数据 v-html html 结构 3. v-if v-show ...

  7. Linux在本地使用yum安装软件(转)

    经常遇到有的linux服务器由于特殊原因,不能连接外网,但是经常需要安装一些软件,尤其是在编译一些包的时候经常由于没有安装一些依存包而报的各种各样的错误,当你找到依存的rpm包去安装的时候,又提示你有 ...

  8. iOS simulator+Appium

    Why are you trying to run iOS automation on a real device? That's a bad idea. iOS Automation on a re ...

  9. Do not use the <section> element as a generic container; this is what <div> is for, especially when the sectioning is only for styling purposes.

    Do not use the <section> element as a generic container; this is what <div> is for, espe ...

  10. 通达OA二次开发 工作流表单中关联查询另外一个工作流方法(源代码)

    一个工作流表单中,怎样方便的查询相关的工作流表单内容.重复打开各个菜单必定须要造成多次点击浪费时间,切换也会带来思路的中断.这里通过js代码的方式把这个问题进行了解决. <style>&l ...