<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExportSelField.aspx.cs" Inherits="GDAS.Web.DocManage.Library.ExportSelField" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>test</title>
    <link href="../../CSS/SubPage.css" rel="Stylesheet" type="text/css" />

<script language="javascript" type="text/javascript">
        function CloneTr() {
            var newRow;
            var table = document.getElementById("tbField");
            if (table.rows[0]) {
                newRow = table.rows[1].cloneNode(true);
            }
            else {
                newRow = document.createElement("tr");
                newRow.appendChild(document.getElementById("td"));
            }
            newRow.style.display = "block";
            table.rows[0].parentElement.appendChild(newRow);
            var maxLength = table.rows.length;
            table.rows[maxLength - 1].cells[0].innerHTML = "<input type='checkbox' style='cursor:hand'/>";
            table.rows[maxLength - 1].cells[1].firstChild.value = "";
            table.rows[maxLength - 1].cells[2].innerHTML = "&nbsp;";
            table.rows[maxLength - 1].cells[3].innerHTML = "&nbsp;";
        }

//删除最后一行,如果是只有一行记录则清空行
        function DeleteTr() {
            var table = document.getElementById("tbField");
            var index = event.srcElement.parentNode.parentNode.rowIndex;
            var result = window.confirm("您确认删除此记录?");
            if (result) {
                table.deleteRow(index);
                return;
            }
        }

function LoadData() {
            var type = "FILE";
            var DocTypeID = "<%=this.DocTypeID%>";
            var response = ExportSelField.GetExportField(type,DocTypeID);
            if (response.error != null) {
                alert(response.error);
                return;
            }
            var dt = response.value;
            var table = document.getElementById("tbField");
            CreateTable(dt, table);
        }

function CreateTable(dt, table) {
            for (var i = 0; i < dt.Rows.length; i++) {
                var row_count;
                CloneTr(table);
                row_count = table.rows.length - 1;
                table.rows[row_count].cells[0].innerHTML = "<input type='checkbox' style='cursor:hand' checked='true'/>";
                table.rows[row_count].cells[1].firstChild.value = (dt.Rows[i].Name == "") ? "&nbsp;" : dt.Rows[i].Name;
                table.rows[row_count].cells[2].innerHTML = (dt.Rows[i].DBColumnName == "") ? "&nbsp;" : dt.Rows[i].DBColumnName;
                table.rows[row_count].cells[3].innerHTML = (dt.Rows[i].DBColumnType == "") ? "&nbsp;" : dt.Rows[i].DBColumnType;
            }
        }

function SelectAll(obj) {
            var table = document.getElementById("tbField");
            for (i = 1; i < table.rows.length; i++) {
                table.rows[i].childNodes[0].childNodes[0].checked = obj.checked;
            }
        }

function Export() {
            window.returnValue = GetValue();
            window.close();
        }

function GetValue() {
            var result = "";
            var iCount = 0;
            var table = document.getElementById("tbField");
            document.getElementById("hdfFieldString").value = "";
            for (var i = 2; i < table.rows.length; i++) {
                if (table.rows[i].childNodes[0].childNodes[0].checked == true) {
                    var field0 = field1 = field2 = "";

field0 = table.rows[i].cells[1].firstChild.value;
                    field1 = table.rows[i].cells[2].innerHTML;
                    field2 = table.rows[i].cells[3].innerHTML;
                    result += GetFieldString(field0, field1, field2) + ",";
                    iCount++;
                }
            }
            if (iCount == 0)
                result = "*";
            return result;
        }

function GetFieldString(cField, eField, FieldType) {
            var result = "";
            switch (FieldType) {
                case "date":
                case "datetime":                        {
                        result = "convert(varchar, " + eField + ", 23) as '" + cField + "'";
                        break;
                    }
                default:
                    {
                        result = eField + " as '" + cField + "'";
                        break;
                    }
            }
            return result;
        }
    </script>

</head>
<body onload="LoadData()">
    <form id="form1" runat="server">
    <div id="main" style="width:95%">
        <fieldset>
            <legend>选择导出字段</legend>
            <table id="tbField" class="grid">
                <tr>
                    <th style="width:60px">
                        <input type='checkbox' id="chkall" style='cursor: hand' title="全选" onclick="SelectAll(this)"
                            checked="checked" />
                    </th>
                    <th>
                        字段名
                    </th>
                    <th style="display: none">
                        fieldname
                    </th>
                    <th style="display: none">
                        数据类型
                    </th>
                </tr>
                <tr style="display: none">
                    <td align="center">
                        <input type='checkbox' />
                    </td>
                    <td align="center">
                        <asp:TextBox ID="TextBox1" runat="server" Width="95%"></asp:TextBox>
                    </td>
                    <td style="display: none">
                        &nbsp;
                    </td>
                    <td style="display: none">
                        &nbsp;
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset style="text-align: center; margin-top: 10px">
            <input type="button" id="btnExport" class="btnS" value="导出" style="width: 60px;
                height: 24px" onclick="Export();" />&nbsp;&nbsp;
            <input type="button" class="btnS" style="width: 60px; height: 24px" value="关闭"
                onclick="javascript:window.close();" />
        </fieldset>
    </div>
    <asp:HiddenField ID="hdfFieldString" runat="server" />
    </form>
</body>
</html>

通过js根据后台数据动态生成一个页面的更多相关文章

  1. js将json数据动态生成表格

    今天开发中遇到需要展示动态数据的问题, 具体要求是后端传来的json字符串,要在前端页面以table表格的形式展示, 其实没啥难的,就是拼接table标签,纯属体力活,于是自己写了个呆萌,保存起来,以 ...

  2. 初探原生js根据json数据动态创建table

    初探原生js根据json数据动态创建table 小生以实习生的职位进入了一家非纯软件的公司做asp.net开发,大半个月下来发现公司里居然没有前端工程师,这令我很诧异,跟着公司做项目,发现前端后台没有 ...

  3. 在Vue中由后台数据循环生成多选框CheckBox时的注意事项

    多选框是一种非常常见的功能,有时候我们会根据后台返回的数据进行多选框渲染,之前做项目时遇到循环生成多选框时,v-model绑定的值会随着选中与取消改变,但页面却不会变化 的情况,后来测试了一下,发现多 ...

  4. 动态生成一个设定好特殊样式的Tlabel,快速生成代码

    动态生成一个设定好特殊样式的Tlabel,快速生成代码: 1.自己先在可视化界面设定一个Label,像这样: 2.选择label,快捷键ctrl+C 复制,粘贴带代码编辑器去,会生成一段这样的窗体代码 ...

  5. 如何用asp.net MVC框架、highChart库从sql server数据库获取数据动态生成柱状图

    如何用asp.net MVC框架.highChart库从sql server数据库获取数据动态生成柱状图?效果大概是这样的,如图: 请问大侠这个这么实现呢?

  6. cglib根据数据动态生成对象

    最近有个任务:根据查询SQL直接导出报表 实现关键是,怎么根据sql查询的数据动态生成对象列表,想到Cglib动态代理实现 废话少说,上代码: 定义动态生成Java Bean类: import jav ...

  7. 根据html页面模板动态生成html页面(c#类)

    本文转载自:http://www.cnblogs.com/yuanbao/archive/2008/01/06/1027985.html点击打开链接 一直以为动态生成静态页面不好做,昨天在网上找了下, ...

  8. Js 日期选择,可以的一个页面中重复使用本JS日历,兼容IE及火狐等主流浏览器,而且界面简洁、美观,操作体验也不错。

    <html> <head> <title>Js日期选择器并自动加入到输入框中</title> <meta http-equiv="con ...

  9. angular js根据json文件动态生成路由状态

    项目上有一个新需求,就是需要根据json文件动态生成路由状态,查阅了一下资料,现在总结一下发出来: 首先项目用到的是angular的UI-路由,所以必须引入angular.js和angular-ui- ...

随机推荐

  1. Esper系列(十三)Splitting and Duplicating Streams

    功能:将同一个事件流分发到其它的事件流中. 格式: 1  ; i < events.length; i++) {   78              EventBean event = even ...

  2. EasyUI + Spring MVC + hibernate实现增删改查导入导出

    (这是一个故事--) 前言 作为一个JAVA开发工程师,我觉得最基本是需要懂前端.后台以及数据库. 练习的内容很基础,包括:基本增删改查.模糊查询.分页查询.树菜单.上传下载.tab页 主管发我一个已 ...

  3. RPi Debian Auto Login

    This guide will show you how to login to a Debian image and start LXDE by simply powering the Pi on. ...

  4. A Tour of Go Concurrency

    The next section covers Go's concurrency primitives. A Tour of Go Goroutines A goroutine is a lightw ...

  5. hdoj 2120 Ice_cream's world I【求成环数】

    Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. hdoj 4548 美素数

    美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...

  7. Keil : Contents missmatch at:08000E84H Verify Failed!

    Keil 下载时出以下错误: Device: STM32F103VB VTarget = 3.300V State of Pins: TCK: 0, TDI: 0, TDO: 1, TMS: 0, T ...

  8. function和感叹号,运算符号的转化

    1.下面的程序经过运算之后,a为true,这个很好理解,但是函数怎么会运行呢? var a = !function(){ alert('message'); }(); console.log(a); ...

  9. 飘逸的python - 使用dis模块进行代码层次的性能剖析

    http://blog.csdn.net/handsomekang/article/details/41479597?utm_source=tuicool&utm_medium=referra ...

  10. java_类泛型基本实例

    package ming; public class Apple2<T> { public T info; public Apple2(T info) { this.info = info ...