Extjs 인쇄

8890 단어 ExtJs
var
 record;
function
 viewScore(){
    var
 ions=Ext.getCmp(""projectGrid"").getSelectionModel().getSelections();
    if
(ions.length>0){
        record=ions[0];
        var
 viewScoreWin=Ext.getCmp(""viewScoreWin"");
        if
(!viewScoreWin){
            viewScoreWin = new
 Ext.Window({
                id: ""viewScoreWin"",
                title: "" "",
                width: 1000,
                height: 350,
                closable: true
,
                layout: ""fit"",
                closeAction: ""close"",
                plain: true
,
                modal: true
,
                iconCls: ""vcard_"",
                bodyStyle: ""padding:5px;"",
                buttonAlign: ""center"",
                buttons: [{
                    text: "" "",
                    handler: function
() {
                        getProjectScoreStore(record.data.Id).reload();
                    }
                },
                {
                    text:"" "",
                    handler:printGrid
                }
                ],
                    items: {
                        xtype: ""panel"",
                        border: false
,
                        frame: false
,
                        baseCls: ""x-plain"",
                        items: [{
                            xtype: ""box"",
                            autoEl: {
                                tag: ""div"",
                                height: 20,
                                id: ""averageScore"" + record.data.Id,
                                html: "" : "" + round2(getProjectScoreStore(record.data.Id).averageScore, 4),
                                style: ""text-align:center;font-size:16px;font-weight:bold;line-height:20px;""
                            }
                        }, {
                            xtype: ""grid"",
                            height: 250,
                            border: false
,
                            viewConfig: { forceFit: true
 },
                            autoFill: true
,
                            id: ""projectScoreGrid"",
                            viewConfig:{forceFit:true
},
                            store: getProjectScoreStore(record.data.Id),
                            cm: new
 Ext.grid.ColumnModel({
                                columns: [
                                new
 Ext.grid.RowNumberer(),
                                { header: "" "", dataIndex: ""UserName"" },
                                {
                                    header: "" "",
                                    dataIndex: ""Score"",
                                    renderer: function
(v) {
                                        if
 (v) {
                                            return
 round2(v, 4)
                                        } else
 {
                                            return
 """"
                                        }
                                    }
                                },
                                { header: "" "", dataIndex: ""Date"", renderer: Ext.util.Format.dateRenderer(""Y-n-j"") },
                                { header: "" "", dataIndex: ""LandLevel"" },
                                { header: "" "", dataIndex: ""LandUse"" },
                                { header: "" "", dataIndex: ""DistrictLandPrice"" },
                                { header: "" "", dataIndex: ""UseAmend"" },
                                { header: "" "", dataIndex: ""DateAmend"" },
                                { header: "" "", dataIndex: ""PlotRatioAmend"" },
                                { header: "" "", dataIndex: ""YearAmend"" },
                                { header: "" "", dataIndex: ""SingleAmend"" },
                                
                                { header: "" "", dataIndex: ""DeveloperLevelAmend""}
                            ]
                            }),
                            sm: new
 Ext.grid.RowSelectionModel({ singleSelect: true
 })
                        }]
                        }
                    });
        }
        viewScoreWin.show();
    }else
{
        Ext.MessageBox.alert("" "","" "");
    }
}
function
 printGrid() {
    var
 gridcontrol = Ext.getCmp(""projectScoreGrid"");
    var
 tableStr = ""<table  style="border:1 black solid; width:100%;"cellpadding=0 cellspacing=0><tr><td colspan=12 align=center style="border:1px black solid;">"";
    var
 cm = gridcontrol.getColumnModel();
    var
 colCount = cm.getColumnCount();
    var
 temp_obj = new
 Array();
    forvar
 i = 1; i < colCount; i++) {
        if
 (cm.isHidden(i) ==
         true
) {

        }
        else
 {
            temp_obj.push(i);
        }
    }
    tableStr = tableStr + "" :"" + round2(getProjectScoreStore(record.data.Id).averageScore, 4)+""</td><tr>"";
    forvar
 i = 0; i < temp_obj.length; i++) {
        tableStr = tableStr + ""<td style="border:1 black solid;">"" + cm.getColumnHeader(temp_obj[i]) + ""</td>"";
    }
    tableStr = tableStr + ""</tr>"";
    var
 store = gridcontrol.getStore();
    var
 recordCount = store.getCount();
    forvar
 i = 0; i < recordCount; i++) {
        var
 r = store.getAt(i);
        forvar
 j = 0; j < temp_obj.length; j++) {
            var
 dateIndex = cm.getDataIndex(temp_obj[j]);
            var
 tdvalue = r.get(dateIndex);
            var
 renderFunc = cm.getRenderer(temp_obj[j]);
            if
 (renderFunc != null
) {
                tdvalue = renderFunc(tdvalue);
            }
            if
 (tdvalue == null
) {
                tdvalue = """";
            }
            tableStr = tableStr + ""<td style="border:1 black solid;">"" + tdvalue + ""</td>"";
        }
        tableStr = tableStr + ""</tr>"";
    }
    tableStr = tableStr + ""</table>"";
    var
 titleHtml = tableStr;
    var
 newwin = window.open(""printer.html"", """", """");
    newwin.document.write(titleHtml);
    newwin.document.location.reload();
    newwin.print();
    newwin.close();
    
}

좋은 웹페이지 즐겨찾기