弹出datagrid内容的dialog框

js:

$(function () {
    $('#risk_suit_list').datagrid({
        queryParams: '',
        url: 'risk/suitlistrest.htm',
        fit: true,
        fitColumns: true,
        striped: true,
        nowrap: true,
        rownumbers: true,
        border: false,
        showPageList: false,
        pagination: true,
        singleSelect: true,
        toolbar: '#risk_suit_list_tool',

        onDblClickRow: function (index, row) {
            $("#risk_suit_list").datagrid('selectRow', index);
            var row = $("#risk_suit_list").datagrid('getSelected');
            if (row) {
                $("#main_window_dialog").dialog({
                    top: 150,
                    width: 700,
                    height: 400,
                    title: '详细信息',
                    href:  'risk/suitdetail.htm?suitId=' + row.id,
                    buttons: [
                        {
                            text: '确定',
                            handler: function () {
                                $('#main_window_dialog').dialog('close');
                            },

                        }]
                });
            }
        },
        columns: [[
            // {field: 'id', checkbox: true, width: 70, halign: "center", align: "center"},
            {field: 'suitName', title: '题套名字', width: 70, halign: "center", align: "center"},
            {
                field: 'appSubmitTime',
                title: '提交时间',
                width: 50,
                halign: "center",
                align: "center",
                formatter: formatDatebox
            },
            {field: 'appOperatorName', title: '提交人', width: 50, halign: "center", align: "center"},
            {field: 'enable', title: '是否选用', width: 50, halign: "center", align: "center",
                formatter: function (value, row, index) {
                    if (value == true) {
                        return '是';
                    }
                }
            },
            {
                field: 'appStatus', title: '当前状态', width: 50, halign: "center", align: "center",
                formatter: function (value, row, index) {
                    if (value == 10 || value == "") {
                        return '待审核';
                    }
                    else if (value == 30) {
                        return '审核通过';
                    }
                    else if (value == -30) {
                        return '审核未通过';
                    }
                }
            },
            {
                field: '操作', title: '操作', width: 100, halign: "center", align: "center",
                formatter: function (value, row, index) {
                    if (row.ICONCLS && row.ICONCLS.length > 0) {
                    } else {
                        var s = '';

                        if (row.appStatus == 10) {
                            s += '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="risk_suit_list_tool.review(' + index + ');" style="color:#75b7ff;">审核</a>';
                        } else {
                            // s += '      ';
                        }

                        return s;
                    }
                }
            }
        ]]
    });
关键代码:
// 弹出框的问题数据加载
    $('#<span style="color:#FF0000;">question_list_select_table</span>').datagrid({
        url:'risk/questionlistrest.htm',
        fit : true,
        fitColumns : true,
        striped : true,
        border : false,
        singleSelect:false,
        columns : [[
            {field: 'id', checkbox: true, width: 70, halign: "center", align: "center"},
            {field: 'content', title: '题目', width: 300, halign: "center", align: "center"},
        ]],
    });
    
    risk_suit_list_tool = {
        reload: function () {
            $('#risk_suit_list').datagrid('reload');
        },
        

        //按钮添加题套
        add: function () {
            $('#<span style="color:#FF0000;">question_list_select_dialog</span>').dialog({
                top: 150,
                width: 570,
                height: 400,
                title: '选择题目',
                closed: false,
                cache: false,
                modal: true,
                buttons: [{
                    text: '下一步',
                    handler: function () {
                        var ids = [];
                        var rows = $('#question_list_select_table').datagrid('getSelections');
                        for (var i = 0; i < rows.length; i++) {
                            ids.push(rows[i].id);
                        };
                        $('#main_window_dialog').dialog({
                            top: 150,
                            width: 570,
                            height: 400,
                            href: 'risk/toaddsuit.htm?ids='+ids,
                            title: '添加套题',
                            buttons: [{
                                text: '确定添加',
                                handler: function () {
                                    $('#risk_suit_add').form('submit', {
                                        url: 'risk/addsuit.htm',
                                        iframe: false,
                                        onSubmit: function (param) {
                                            param.questionIds = $('input[name="questionId"]').map(function () {
                                                return $(this).val();
                                            }).get().join(", ");
                                            param.questionOrders = $('input[name="questionOrder"]').map(function () {
                                                return $(this).val();
                                            }).get().join(", ");
                                            param.scores = $('input[name="score"]').map(function () {
                                                return $(this).val();
                                            }).get().join(", ");
                                            // return $(this).form('validate');
                                        },
                                        success: function (data) {
                                            $('#main_window_dialog').dialog('close');
                                            $('#risk_question_list').datagrid('clearSelections');
                                            if ($('#risk_suit_list').length > 0) {
                                                $('#risk_suit_list').datagrid('reload');
                                            }
                                        }
                                    })
                                }
                            },{
                            text: '取消',
                                handler: function () {
                                    $('#main_window_dialog').dialog('close');
                                }
                            }]

                        }),
                        $('#question_list_select_dialog').dialog('close');

                    }
                },
            });    

        },
}
jsp:
<div id="risk_suit_list_tool" style="padding:5px;">
        <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="risk_suit_list_tool.add();">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="risk_suit_list_tool.reload();">刷新</a>
</div>
<div id="risk_suit_list"></div>

<div id="question_list_select_dialog">
        <!--问题列表的datagrid-->
        <table id="question_list_select_table"></table>
</div>

其实最主要的就是用一个div包着一个table,table其实就是一个datagrid,然后div是一个dialog。

你可能感兴趣的:(弹出datagrid内容的dialog框)