dhtmlxGrid——创建前端页面的模板

使用dhtmlxGrid前端框架(dhtmlx.js、toolbar.js、index.js)并结合jQuery、select2、Ajax进行设计

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/dhtmlx/codebase/roboto.css" rel="stylesheet" />
    <link href="~/Content/dhtmlx/codebase/dhtmlx.css" rel="stylesheet" />
    <link href="~/Content/dhtmlx/skins/skyblue/dhtmlx.css" rel="stylesheet" />
    <script src="~/scripts/jquery-1.10.2.js"></script>
    <script src="~/Content/dhtmlx/codebase/dhtmlx.js"></script>
    <script src="~/Content/MES/toolbar.js"></script>
    <script src="~/Content/MES/dateFormater.js"></script>
    <title>Index</title>
    <script type="text/javascript">
        var myGrid;
        var dhxTabGridFlowDetail;
        var dhxTabGridFlowUserDetail;
        var dhxTabGridFlowDefectDetail;
        var dhxTabGridFlowModelDetail;
        var dhxTabGridFlowShopDetail;
        var myGridFirstData
        

        $(document).ready(function () {
            doOnLoad();

            $("#btnSearch").click(function () {
                
                myGrid.clearAndLoad("../Flow/GetDataList?name=" + $("#name").val(), "js");
                
                
                dhxTabGridFlowDetail.clearAndLoad("../Flow/GetDataListFlow?id=" + $("#name").val(), "js");
   

                //dhxTabGridFlowUserDetail.clearAndLoad("../Flow/GetDataListFlowUser?id=" + dataItem, "js");

                window.top.index.closeLoading();
            });
        });
        function doOnLoad() {
            /***
             * 审核流程
             * 
             * */
            myGrid = new dhtmlXGridObject('gridbox');
            myGrid.selMultiRows = true;
            myGrid.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //myGrid.setDateFormat("%Y/%m/%d");
            myGrid.setHeader(",Id,流程ID,流程名称,是否审核,是否启用,创建人,创建时间,修改人,修改时间,备注");
            myGrid.setColumnIds(",ID,FLOWID,FLOWNAME,ISAPPROVE,ISACTIVE,CREATE_USER,CREATE_TIME,UPDATE_USER,UPDATE_TIME,REMARK");
            myGrid.setInitWidths("40,100,100,100,100,100,100,100,100,100,100");
            myGrid.setColAlign("center,left,left,left,left,left,left,left,left,left,left");
            myGrid.setColTypes("ch,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed");
            myGrid.setColumnHidden(1, true);
            myGrid.enableAutoWidth(true);
            myGrid.enableAutoHeight(true);
            myGrid.enableAutoSaving(false);
            myGrid.enableEditEvents(true);
            myGrid.attachEvent("onRowDblClicked", function (rowId) {
                var data = myGrid.cells(rowId, 1).getValue();
                window.top.index.createWindow(data, "编辑流程资料", "../Flow/Edit?id=" + data, 1280, 600, null, null);
            });
            myGrid.attachEvent("onRowSelect", function (rowId) {
                var data = myGrid.cells(rowId, 2).getValue();
                dhxTabGridFlowDetail.clearAndLoad("../Flow/GetDataListFlow?id=" + data, "js");
                //dhxTabGridFlowDefectDetail.clearAndLoad("../Flow/GetDataListFlowDefect?id=" + data, "js");

                window.top.index.closeLoading();
            });
            myGrid.attachEvent("onXLS", function () {
                window.top.index.openLoading();
            });
            myGrid.init();
            myGrid.i18n.paging = {
                //results: "Results",
                records: "行记录从 ",
                to: " 到 ",
                page: "页面 ",
                perpage: "行每页",
                //first: "To first Page",
                //previous: "Previous Page",
                //found: "Found records",
                //next: "Next Page",
                //last: "To last Page",
                //of: " of ",
                notfound: "没找到记录"
            };
            myGrid.enablePaging(true, 15, 5, "recinfoArea");
            myGrid.setPagingSkin("toolbar", "dhx_skyblue");
            myGrid.load("../Flow/GetDataList?posStart=0&count=15", "js");
            myGrid.xmlFileUrl = "../Flow/GetDataList?name=" + $("#name").val();

            myGrid.attachEvent("onDataReady", function () {
                
                window.top.index.closeLoading();

                var rowsBuffer = myGrid.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            myGrid.rowsBuffer[i].data.ISACTIVE = "启用";
                        else
                            myGrid.rowsBuffer[i].data.ISACTIVE = "禁用";

                        var val = rowsBuffer[i].data.ISAPPROVE;
                        if (val == 10)
                            myGrid.rowsBuffer[i].data.ISAPPROVE = "Y";
                        else
                            myGrid.rowsBuffer[i].data.ISAPPROVE = "N";
                    }
                }
            });


            document.getElementById("tabber").style.width = myGrid.width;//"1100px";
            document.getElementById("tabber").style.height = "600px";

            //创建页签
            var myTabbar = new dhtmlXTabBar("tabber");
            myTabbar.setSizes();

            //页签选项
            myTabbar.addTab("tabFlowDetail", "流程配置", 100, 0, true, false);
            myTabbar.addTab("tabFlowDefect", "坏品代码", 100, 1, false, false);
            myTabbar.addTab("tabFlowModel", "品种", 100, 2, false, false);
            myTabbar.addTab("tabFlowShop", "车间", 100, 3, false, false);
            myTabbar.addTab("tabFlowUser", "审核人", 100, 9, false, false);//审核人放最后

            //生成网格
            dhxTabGridFlowModelDetail = myTabbar.tabs("tabFlowModel").attachGrid();
            dhxTabGridFlowShopDetail = myTabbar.tabs("tabFlowShop").attachGrid();
            dhxTabGridFlowDefectDetail = myTabbar.tabs("tabFlowDefect").attachGrid();
            dhxTabGridFlowUserDetail = myTabbar.tabs("tabFlowUser").attachGrid();
            dhxTabGridFlowDetail = myTabbar.tabs("tabFlowDetail").attachGrid();

            //品种代码配置按钮
            var dhxToolBarModelDetail = myTabbar.cells("tabFlowModel").attachToolbar();
            dhxToolBarModelDetail.setIconset("awesome");
            dhxToolBarModelDetail.addButton("btnAddModelDetail", 1, "新增", "fa fa-plus-square-o");
            dhxToolBarModelDetail.addButton("btnEditModelDetail", 2, "编辑", "fa fa-edit");
            dhxToolBarModelDetail.addButton("btnDelModelDetail", 3, "删除", "fa fa-trash-o");

            //车间代码配置按钮
            var dhxToolBarShopDetail = myTabbar.cells("tabFlowShop").attachToolbar();
            dhxToolBarShopDetail.setIconset("awesome");
            dhxToolBarShopDetail.addButton("btnAddShopDetail", 1, "新增", "fa fa-plus-square-o");
            dhxToolBarShopDetail.addButton("btnEditShopDetail", 2, "编辑", "fa fa-edit");
            dhxToolBarShopDetail.addButton("btnDelShopDetail", 3, "删除", "fa fa-trash-o");

            //坏品代码配置按钮
            var dhxToolBarDefectDetail = myTabbar.cells("tabFlowDefect").attachToolbar();
            dhxToolBarDefectDetail.setIconset("awesome");
            dhxToolBarDefectDetail.addButton("btnAddDefectDetail", 1, "新增", "fa fa-plus-square-o");
            dhxToolBarDefectDetail.addButton("btnEditDefectDetail", 2, "编辑", "fa fa-edit");
            dhxToolBarDefectDetail.addButton("btnDelDefectDetail", 3, "删除", "fa fa-trash-o");

            //审核人配置按钮
            var dhxToolBarUserDetail = myTabbar.cells("tabFlowUser").attachToolbar();
            dhxToolBarUserDetail.setIconset("awesome");
            dhxToolBarUserDetail.addButton("btnAddUserDetail", 1, "新增", "fa fa-plus-square-o");
            dhxToolBarUserDetail.addButton("btnEditUserDetail", 2, "编辑", "fa fa-edit");
            dhxToolBarUserDetail.addButton("btnDelUserDetail", 3, "删除", "fa fa-trash-o");

            //流程配置按钮
            var dhxToolBarDetail = myTabbar.cells("tabFlowDetail").attachToolbar();
            dhxToolBarDetail.setIconset("awesome");
            dhxToolBarDetail.addButton("btnDelDetail", 0, "删除", true, false);
            dhxToolBarDetail.addButton("btnEditDetail", 0, "编辑", true, false);
            dhxToolBarDetail.addButton("btnAddDetail", 0, "新增", true, false);


            dhxToolBarModelDetail.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDelModelDetail":
                        var count = 0;
                        var ids = "";
                        dhxTabGridFlowModelDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowModelDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridFlowModelDetail.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Flow/DelFlowModel",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEditModelDetail":
                        var count = 0;
                        var sid;
                        dhxTabGridFlowModelDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowModelDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridFlowModelDetail.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "流程配置", "../Flow/EditFlowModel?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAddModelDetail":
                        //当前选中行
                        var checkIDs = dhxTabGridFlowDetail.getSelectedRowId();
                        //选中行ID
                        var sid = dhxTabGridFlowDetail.cells(checkIDs, 3).getValue();
                        var fitem = dhxTabGridFlowDetail.cells(checkIDs, 4).getValue();

                        var win = window.top.index.createWindow("",
                            "流程配置",
                            "../Flow/AddFlowModel?Id=" + sid + "&flowitem=" + fitem,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });




            dhxToolBarShopDetail.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDelShopDetail":
                        var count = 0;
                        var ids = "";
                        dhxTabGridFlowShopDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowShopDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridFlowShopDetail.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Flow/DelFlowShop",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEditShopDetail":
                        var count = 0;
                        var sid;
                        dhxTabGridFlowShopDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowShopDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridFlowShopDetail.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "流程配置", "../Flow/EditFlowShop?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAddShopDetail":
                        //当前选中行
                        var checkIDs = dhxTabGridFlowDetail.getSelectedRowId();
                        //选中行ID
                        var sid = dhxTabGridFlowDetail.cells(checkIDs, 3).getValue();
                        var fitem = dhxTabGridFlowDetail.cells(checkIDs, 4).getValue();

                        var win = window.top.index.createWindow("",
                            "流程配置",
                            "../Flow/AddFlowShop?Id=" + sid + "&flowitem=" + fitem,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });





            dhxToolBarDefectDetail.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDelDefectDetail":
                        var count = 0;
                        var ids = "";
                        dhxTabGridFlowDefectDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowDefectDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridFlowDefectDetail.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Flow/DelFlowDefect",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEditDefectDetail":
                        var count = 0;
                        var sid;
                        dhxTabGridFlowDefectDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowDefectDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridFlowDefectDetail.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "坏品代码配置", "../Flow/EditFlowDefect?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAddDefectDetail":
                        //当前选中行
                        var checkIDs = dhxTabGridFlowDetail.getSelectedRowId();
                        //选中行ID
                        var sid = dhxTabGridFlowDetail.cells(checkIDs, 3).getValue();
                        var fitem = dhxTabGridFlowDetail.cells(checkIDs, 4).getValue();

                        var win = window.top.index.createWindow("",
                            "坏品代码配置",
                            "../Flow/AddFlowDefect?Id=" + sid + "&flowitem=" + fitem,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });

            dhxToolBarUserDetail.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDelUserDetail":
                        var count = 0;
                        var ids = "";
                        dhxTabGridFlowUserDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowUserDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridFlowUserDetail.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Flow/DelFlowUser",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEditUserDetail":
                        var count = 0;
                        var sid;
                        dhxTabGridFlowUserDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowUserDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridFlowUserDetail.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "流程配置", "../Flow/EditFlowUser?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAddUserDetail":
                        //当前选中行
                        var checkIDs = dhxTabGridFlowDetail.getSelectedRowId();
                        //选中行ID
                        var sid = dhxTabGridFlowDetail.cells(checkIDs, 1).getValue();

                        var sshopid = "";
                        var smodelid = "";


                        //当前车间选中行
                        var checkShopIDs = dhxTabGridFlowShopDetail.getSelectedRowId();
                        console.log("车间行:" + checkShopIDs);

                        //当前品种选中行
                        var checkModelIDs = dhxTabGridFlowModelDetail.getSelectedRowId();
                        console.log("品种行:" + checkModelIDs);

                        if (checkShopIDs != null) {
                            sshopid = dhxTabGridFlowShopDetail.cells(checkShopIDs, 2).getValue();
                            console.log("车间编号:" + sshopid);
                        }

                        if (checkModelIDs != null) {
                            smodelid = dhxTabGridFlowModelDetail.cells(checkModelIDs, 2).getValue();
                            console.log("品种编码:" + smodelid);
                        }


                        var win = window.top.index.createWindow("",
                            "流程配置",
                            "../Flow/AddFlowUser?Id=" + sid + "&shopid=" + sshopid + "&model=" + smodelid,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });


            dhxToolBarDetail.attachEvent("onClick", function (id) {
                switch (id) {
                    case "btnDelDetail":
                        var count = 0;
                        var ids = "";
                        dhxTabGridFlowDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                if (ids.length > 0)
                                    ids += ",";
                                ids += dhxTabGridFlowDetail.cells(rowId, 1).getValue();
                            }

                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        }
                        else {
                            window.top.index.confirm_warning("系统提示",
                                "确定删除选中的【" + count + "】条记录吗?",
                                function () {
                                    $.ajax({
                                        url: "../Flow/DelFlowDetail",
                                        type: "POST",
                                        data: { ids: ids },
                                        success: function (res) {
                                            if (res.Result == 10)
                                                doOnLoad();
                                            else
                                                window.top.index.alert_warning("系统提示", res.Data, "确定", null);
                                        }
                                    });
                                },
                                function () {
                                    window.top.index.alert_warning("系统提示", "用户取消操作!", "确定", null);
                                });
                        }

                        break;
                    case "btnEditDetail":
                        var count = 0;
                        var sid;
                        dhxTabGridFlowDetail.forEachRow(function (rowId) {
                            var val = dhxTabGridFlowDetail.cells(rowId, 0).getValue();
                            if (val == 1) {
                                count += 1;
                                sid = dhxTabGridFlowDetail.cells(rowId, 1).getValue();
                            }
                        });
                        if (count == 0) {
                            window.top.index.alert_warning("系统提示", "请至少选择一条记录!", "确定", null);
                        } else if (count > 1) {
                            window.top.index.alert_warning("系统提示", "只能选择一条记录!", "确定", null);
                        } else {
                            window.top.index.createWindow("", "流程配置", "../Flow/EditFlow?Id=" + sid, 1280, 600, null, null);
                        }
                        break;
                    case "btnAddDetail":
                        //当前选中行
                        var checkIDs = myGrid.getSelectedRowId();
                        //选中行ID
                        var sid = myGrid.cells(checkIDs, 1).getValue();

                        var win = window.top.index.createWindow("",
                            "流程配置",
                            "../Flow/AddFlow?Id=" + sid,
                            1280,
                            600,
                            function () {
                                $("DataForm", ifr.contentWindow.document).submit();
                            },
                            function () {
                                window.top.index.message_err("执行取消动作!");
                            });
                        break;
                }
            });


            /***
             * 车间代码
             *
             * */
            dhxTabGridFlowShopDetail.selMultiRows = true;
            dhxTabGridFlowShopDetail.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //dhxTabGridFlowShopDetail.setDateFormat("%Y/%m/%d");
            dhxTabGridFlowShopDetail.setHeader(",Id,车间代码,是否有效,备注");
            dhxTabGridFlowShopDetail.setColumnIds(",ID,SHOP_NO,ISACTIVE,REMARK");
            dhxTabGridFlowShopDetail.setInitWidths("40,150,150,150,150");
            dhxTabGridFlowShopDetail.setColAlign("center,left,left,left,left");
            dhxTabGridFlowShopDetail.setColTypes("ch,ed,ed,ed,ed");
            dhxTabGridFlowShopDetail.setColumnHidden(1, true);
            dhxTabGridFlowShopDetail.enableAutoWidth(true);
            dhxTabGridFlowShopDetail.enableAutoHeight(true);
            dhxTabGridFlowShopDetail.enableAutoSaving(false);
            dhxTabGridFlowShopDetail.enableEditEvents(true);
            dhxTabGridFlowShopDetail.attachEvent("onRowSelect", function (rowId) {
                
                var checkFlowIDs = dhxTabGridFlowDetail.getSelectedRowId();
                var FID = dhxTabGridFlowDetail.cells(checkFlowIDs, 3).getValue();
                var FItem = dhxTabGridFlowDetail.cells(checkFlowIDs, 4).getValue();
                var SHOP_NO = dhxTabGridFlowShopDetail.cells(rowId, 2).getValue();
                

                dhxTabGridFlowUserDetail.clearAndLoad("../Flow/GetDataListFlowUser?fid=" + FID + "&fitem=" + FItem + "&shop_no=" + SHOP_NO, "js");
                //window.top.index.closeLoading();
            });
            dhxTabGridFlowShopDetail.attachEvent("onXLS", function () {
                //window.top.index.openLoading();
            });
            dhxTabGridFlowShopDetail.init();
            //dhxTabGridFlowShopDetail.enablePaging(true, 15, 5, "recinfoArea");
            dhxTabGridFlowShopDetail.attachFooter(["<div id='grid_5_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridFlowShopDetail.enablePaging(true, 15, 5, 'grid_5_recinfoArea');
            dhxTabGridFlowShopDetail.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridFlowShopDetail.load("../Flow/GetDataListFlowShop", "js");
            dhxTabGridFlowShopDetail.xmlFileUrl = "../Flow/GetDataListFlowShop?name=" + $("#name").val();
            dhxTabGridFlowShopDetail.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridFlowShopDetail.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            dhxTabGridFlowShopDetail.rowsBuffer[i].data.ISACTIVE = "Y";
                        else
                            dhxTabGridFlowShopDetail.rowsBuffer[i].data.ISACTIVE = "N";
                    }
                }
            });



            /***
             * 品种
             *
             * */
            dhxTabGridFlowModelDetail.selMultiRows = true;
            dhxTabGridFlowModelDetail.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            dhxTabGridFlowModelDetail.setHeader(",Id,品种,是否有效,备注");
            dhxTabGridFlowModelDetail.setColumnIds(",ID,MODEL,ISACTIVE,REMARK");
            dhxTabGridFlowModelDetail.setInitWidths("40,150,150,150,150");
            dhxTabGridFlowModelDetail.setColAlign("center,left,left,left,left");
            dhxTabGridFlowModelDetail.setColTypes("ch,ed,ed,ed,ed");
            dhxTabGridFlowModelDetail.setColumnHidden(1, true);
            dhxTabGridFlowModelDetail.enableAutoWidth(true);
            dhxTabGridFlowModelDetail.enableAutoHeight(true);
            dhxTabGridFlowModelDetail.enableAutoSaving(false);
            dhxTabGridFlowModelDetail.enableEditEvents(true);
            dhxTabGridFlowModelDetail.attachEvent("onRowSelect", function (rowId) {

                var checkFlowIDs = dhxTabGridFlowDetail.getSelectedRowId();
                var FID = dhxTabGridFlowDetail.cells(checkFlowIDs, 3).getValue();
                var FItem = dhxTabGridFlowDetail.cells(checkFlowIDs, 4).getValue();
                var model = dhxTabGridFlowModelDetail.cells(rowId, 2).getValue();


                dhxTabGridFlowUserDetail.clearAndLoad("../Flow/GetDataListFlowUser?fid=" + FID + "&fitem=" + FItem + "&model=" + model, "js");
            });
            dhxTabGridFlowModelDetail.attachEvent("onXLS", function () {
                //window.top.index.openLoading();
            });
            dhxTabGridFlowModelDetail.init();
            //dhxTabGridFlowModelDetail.enablePaging(true, 15, 5, "recinfoArea");
            dhxTabGridFlowModelDetail.attachFooter(["<div id='grid_4_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridFlowModelDetail.enablePaging(true, 15, 5, 'grid_4_recinfoArea');
            dhxTabGridFlowModelDetail.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridFlowModelDetail.load("../Flow/GetDataListFlowModel", "js");
            dhxTabGridFlowModelDetail.xmlFileUrl = "../Flow/GetDataListFlowModel?name=" + $("#name").val();
            dhxTabGridFlowModelDetail.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridFlowModelDetail.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            dhxTabGridFlowModelDetail.rowsBuffer[i].data.ISACTIVE = "Y";
                        else
                            dhxTabGridFlowModelDetail.rowsBuffer[i].data.ISACTIVE = "N";
                    }
                }
            });


            /***
             * 坏品代码
             *
             * */
            dhxTabGridFlowDefectDetail.selMultiRows = true;
            dhxTabGridFlowDefectDetail.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //dhxTabGridFlowDefectDetail.setDateFormat("%Y/%m/%d");
            dhxTabGridFlowDefectDetail.setHeader(",Id,坏品代码,坏品名称,是否有效,方向,备注");
            dhxTabGridFlowDefectDetail.setColumnIds(",ID,DEFECTCODE,DEFECTNAME,ISACTIVE,DIRECT,REMARK");
            dhxTabGridFlowDefectDetail.setInitWidths("40,150,150,150,100,100,150");
            dhxTabGridFlowDefectDetail.setColAlign("center,left,left,left,left,left,left");
            dhxTabGridFlowDefectDetail.setColTypes("ch,ed,ed,ed,ed,ed,ed");
            dhxTabGridFlowDefectDetail.setColumnHidden(1, true);
            dhxTabGridFlowDefectDetail.enableAutoWidth(true);
            dhxTabGridFlowDefectDetail.enableAutoHeight(true);
            dhxTabGridFlowDefectDetail.enableAutoSaving(false);
            dhxTabGridFlowDefectDetail.enableEditEvents(true);
            dhxTabGridFlowDefectDetail.attachEvent("onXLS", function () {
                window.top.index.openLoading();
            });
            dhxTabGridFlowDefectDetail.init();
            //dhxTabGridFlowDefectDetail.enablePaging(true, 15, 5, "recinfoArea");
            dhxTabGridFlowDefectDetail.attachFooter(["<div id='grid_3_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridFlowDefectDetail.enablePaging(true, 15, 5, 'grid_3_recinfoArea');
            dhxTabGridFlowDefectDetail.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridFlowDefectDetail.load("../Flow/GetDataListFlowDefect", "js");
            dhxTabGridFlowDefectDetail.xmlFileUrl = "../Flow/GetDataListFlowDefect?name=" + $("#name").val();
            dhxTabGridFlowDefectDetail.attachEvent("onDataReady", function () {
                window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridFlowDefectDetail.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            dhxTabGridFlowDefectDetail.rowsBuffer[i].data.ISACTIVE = "Y";
                        else
                            dhxTabGridFlowDefectDetail.rowsBuffer[i].data.ISACTIVE = "N";

                        val = rowsBuffer[i].data.DIRECT;
                        if (val == 10)
                            dhxTabGridFlowDefectDetail.rowsBuffer[i].data.DIRECT = "Y";
                        else
                            dhxTabGridFlowDefectDetail.rowsBuffer[i].data.DIRECT = "N";
                    }
                }
            });


            /***
             * 审核人员
             *
             * */
            dhxTabGridFlowUserDetail.selMultiRows = true;
            dhxTabGridFlowUserDetail.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //dhxTabGridFlowUserDetail.setDateFormat("%Y/%m/%d");
            dhxTabGridFlowUserDetail.setHeader(",Id,审核人工号,审核人姓名,是否有效,备注");
            dhxTabGridFlowUserDetail.setColumnIds(",ID,USER_NO,USER_NAME,ISACTIVE,REMARK");
            dhxTabGridFlowUserDetail.setInitWidths("40,150,150,150,150,150");
            dhxTabGridFlowUserDetail.setColAlign("center,left,left,left,left,left");
            dhxTabGridFlowUserDetail.setColTypes("ch,ed,ed,ed,ed,ed");
            dhxTabGridFlowUserDetail.setColumnHidden(1, true);
            dhxTabGridFlowUserDetail.enableAutoWidth(true);
            dhxTabGridFlowUserDetail.enableAutoHeight(true);
            dhxTabGridFlowUserDetail.enableAutoSaving(false);
            dhxTabGridFlowUserDetail.enableEditEvents(true);
            dhxTabGridFlowUserDetail.attachEvent("onRowSelect", function (rowId) {
                //var data = dhxTabGridFlowUserDetail.cells(rowId, 2).getValue();
                //dhxTabGridLim.clearAndLoad("../Flow/GetDataListFlow?id=" + data, "js");
                //window.top.index.closeLoading();
            });
            dhxTabGridFlowUserDetail.attachEvent("onXLS", function () {
                //window.top.index.openLoading();
            });
            dhxTabGridFlowUserDetail.init();
            //dhxTabGridFlowUserDetail.enablePaging(true, 15, 5, "recinfoArea");
            dhxTabGridFlowUserDetail.attachFooter(["<div id='grid_2_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridFlowUserDetail.enablePaging(true, 15, 5, 'grid_2_recinfoArea');
            dhxTabGridFlowUserDetail.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridFlowUserDetail.load("../Flow/GetDataListFlowUser", "js");
            dhxTabGridFlowUserDetail.xmlFileUrl = "../Flow/GetDataListFlowUser?name=" + $("#name").val();
            dhxTabGridFlowUserDetail.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridFlowUserDetail.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.ISACTIVE;
                        if (val == 10)
                            dhxTabGridFlowUserDetail.rowsBuffer[i].data.ISACTIVE = "Y";
                        else
                            dhxTabGridFlowUserDetail.rowsBuffer[i].data.ISACTIVE = "N";
                    }
                }
            });


            /***
             * 流程配置
             *
             * */

            dhxTabGridFlowDetail.selMultiRows = true;
            dhxTabGridFlowDetail.setImagePath("../../../Content/dhtmlx/codebase/imgs/");
            //myGrid.setDateFormat("%Y/%m/%d");
            dhxTabGridFlowDetail.setHeader(",Id,序号,审核流程,审核组,备注");//审核人工号,审核人姓名,
            dhxTabGridFlowDetail.setColumnIds(",ID,SEQNO,FLOWID,FLOWITEM,REMARK");//USER_NO,USER_NAME,
            dhxTabGridFlowDetail.setInitWidths("40,60,150,150,150,150");//,100,100
            dhxTabGridFlowDetail.setColAlign("center,left,left,left,left,left");//,left,left
            dhxTabGridFlowDetail.setColTypes("ch,ed,ed,ed,ed,ed");//,ed,ed
            dhxTabGridFlowDetail.setColumnHidden(1, true);
            dhxTabGridFlowDetail.enableAutoWidth(true);
            dhxTabGridFlowDetail.enableAutoHeight(true);
            dhxTabGridFlowDetail.enableAutoSaving(false);
            dhxTabGridFlowDetail.enableEditEvents(true);

            dhxTabGridFlowDetail.attachEvent("onRowSelect", function (rowId) {
                var FID = dhxTabGridFlowDetail.cells(rowId, 3).getValue();
                var FItem = dhxTabGridFlowDetail.cells(rowId, 4).getValue();
                dhxTabGridFlowUserDetail.clearAndLoad("../Flow/GetDataListFlowUser?fid=" + FID + "&fitem=" + FItem, "js");
                dhxTabGridFlowDefectDetail.clearAndLoad("../Flow/GetDataListFlowDefect?id=" + FID + "&fitem=" + FItem, "js");
                dhxTabGridFlowModelDetail.clearAndLoad("../Flow/GetDataListFlowModel?id=" + FID + "&fitem=" + FItem, "js");
                dhxTabGridFlowShopDetail.clearAndLoad("../Flow/GetDataListFlowShop?id=" + FID + "&fitem=" + FItem, "js");
                window.top.index.closeLoading();
            });

            dhxTabGridFlowDetail.attachEvent("onXLS", function () {
                //window.top.index.openLoading();
            });
            dhxTabGridFlowDetail.init();
            //dhxTabGridFlowDetail.enablePaging(true, 15, 5, "recinfoArea");
            dhxTabGridFlowDetail.attachFooter(["<div id='grid_1_recinfoArea' style='width:100%;height:100%'></div>", "#cspan", "#cspan", "#cspan", "#cspan", "#cspan"], ['height:100%;text-align:left;background:transparent;border-color:white;padding:0px;']);
            dhxTabGridFlowDetail.enablePaging(true, 15, 5, 'grid_1_recinfoArea');
            dhxTabGridFlowDetail.setPagingSkin("toolbar", "dhx_skyblue");
            dhxTabGridFlowDetail.load("../Flow/GetDataListFlow", "js");
            dhxTabGridFlowDetail.xmlFileUrl = "../Flow/GetDataList?name=" + $("#name").val();
            dhxTabGridFlowDetail.attachEvent("onDataReady", function () {
                //window.top.index.closeLoading();

                var rowsBuffer = dhxTabGridFlowDetail.rowsBuffer;
                for (var i = 0; i < rowsBuffer.length; i++) {
                    if (rowsBuffer[i] == undefined || rowsBuffer[i].data == undefined)
                        continue;
                    else {
                        var val = rowsBuffer[i].data.STATUS;
                        if (val == 10)
                            dhxTabGridFlowDetail.rowsBuffer[i].data.STATUS = "启用";
                        else
                            dhxTabGridFlowDetail.rowsBuffer[i].data.STATUS = "禁用";
                    }
                }
            });
        }

        function getData() {
            var flowid = $("#name").val();
            var data = { flowid: flowid };
            return data;
        }

        function GetFile(fileName) {
            window.location.href = "../Flow/GetExportFile?fileName=" + fileName;
        }

        function checkStatus(operation) {
            return true;
        }
    </script>
</head>
<body class="form-inline container-fluid" style="overflow-y:auto; overflow-x:auto;">
    <table cellpadding="0" cellspacing="0" style="overflow-x: auto; clear:both;">
        <tr>
            <td>
                <div class="dhxform_obj_dhx_skyblue" style="font-size:12px;">
                    <div class="dhxform_base">
                        <div class="dhxform_item_label_left">
                            <div class="dhxform_label dhxform_label_align_left" style="font-weight:normal;">
                                <label>流程ID:</label>
                            </div>
                            <div class="dhxform_control">
                                <input type="text" id="name" />
                            </div>
                        </div>
                    </div>
                    <div class="dhxform_base">
                        <div class="dhxform_item_label_left">
                            <div class="dhxform_btn" id="btnSearch" style="margin:-2px 5px 5px 5px;">
                                <div class="dhxform_btn_txt">查询</div>
                                <div class="dhxform_btn_filler" disabled="true"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="gridbox"></div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="recinfoArea"></div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="tabber"></div>
            </td>
        </tr>


    </table>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
dhtmlxGrid是一款基于JavaScript的交互式网格,支持各种数据源和格式。它还提供了导出表格数据的功能,可以将表格数据导出为Excel、PDF和CSV等格式。 以下是使用dhtmlxGrid导出表格数据的步骤: 1. 引入dhtmlxGrid库文件和导出插件文件。你可以从官网下载最新的dhtmlxGrid库和导出插件,也可以使用CDN链接引入。 ```html <!-- 引入dhtmlxGrid库文件 --> <script src="https://cdn.dhtmlx.com/grid/edge/dhtmlxgrid.js"></script> <link rel="stylesheet" href="https://cdn.dhtmlx.com/grid/edge/dhtmlxgrid.css"> <!-- 引入导出插件文件 --> <script src="https://cdn.dhtmlx.com/excel/dhtmlxgrid_export.js"></script> ``` 2. 创建表格对象。你需要在HTML页面创建一个div元素,然后使用JavaScript代码初始化dhtmlxGrid对象,并将其绑定到该div元素上。 ```html <div id="gridbox" style="width: 100%; height: 400px;"></div> <script> var grid = new dhtmlXGridObject('gridbox'); grid.setHeader("Column 1, Column 2, Column 3"); grid.setInitWidths("100,200,*"); grid.init(); </script> ``` 3. 加载表格数据。你可以使用dhtmlxGrid提供的API,从不同的数据源加载表格数据,比如XML、JSON、CSV等。 ```javascript grid.load("data.xml", "xml"); // 从XML文件加载数据 grid.load("data.json", "json"); // 从JSON文件加载数据 grid.load("data.csv", "csv"); // 从CSV文件加载数据 ``` 4. 导出表格数据。你可以使用dhtmlxGrid提供的API,将表格数据导出为Excel、PDF和CSV等格式。 ```javascript // 导出为Excel格式 grid.toExcel("http://localhost/export.php"); // 导出为PDF格式 grid.toPDF("http://localhost/export.php"); // 导出为CSV格式 grid.toCSV("http://localhost/export.php"); ``` 在上面的代码中,我们使用了toExcel、toPDF和toCSV方法来将表格数据导出为Excel、PDF和CSV格式。这些方法需要一个服务器端的脚本来处理导出操作,我们可以将导出数据发送到该脚本并在脚本中进行处理和输出导出文件。 以上就是使用dhtmlxGrid导出表格数据的基本流程。你可以根据自己的需求,对表格样式和导出格式进行进一步的定制和配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值