0

我有一个绑定到 iggrid 的数据源,其中语句列数据返回链接

a href=E:\FILES\STATEMENTS\DAILYSTATEMENTS\20150127\R-956-10103.pdf

代码如下

$(function () {
       var data = <%= GetAccountInformationJSON() %>;


        if ( data != '' )
        {
            $("#gridAccountInformation").igGrid({
                height: ((content_height - HeaderHeight) / 2) +"px",
                width: "100%",
                columns: [
                    {headerText: "Account", key:"Account", dataType: "string"},
                    {headerText: "Office", key:"Office", dataType: "string"},
                    {headerText: "Balance", key:"Balance", dataType: "number", format: "0#,###"},
                    {headerText: "Init Mrg", key:"InitMarginReq", dataType: "number", format: "0#,###"},
                    {headerText: "OTE", key:"OpenTrdEqty", dataType: "number", format: "0#,###"},
                    {headerText: "Total Eqty", key:"TotalEqty", dataType: "number", format: "0#,###"},
                    {headerText: "Liq. Val", key:"LiquidatingVal", dataType: "number", format: "0#,###"},
                    {headerText: "Ex/Def", key:"ExcessDeficit", dataType: "number", format: "0#,###"},
                    {headerText: "Statement", key:"Statement", dataType: "string"}
                ]
                ,

                features:[
                     {
                         name: "Resizing",


                     }

                ],
                dataRendered: function (evt, ui) {

                    ui.owner.element.find("tr th:nth-child(1)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(2)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(3)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(4)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(5)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(6)").css("text-align", "center");
                    ui.owner.element.find("tr th:nth-child(7)").css("text-align", "center");  
                    ui.owner.element.find("tr th:nth-child(8)").css("text-align", "center");   
                    ui.owner.element.find("tr th:nth-child(9)").css("text-align", "center");
                }
                ,
                dataSource: data //JSON Array defined above   

            });

            $("#gridAccountInformation").igGrid("option", "datasource", data);
        }

    });

在上面的 iggrid 中,Stmt 将显示为链接。单击它时,我需要下载数据源中存在的文件。

例如:a href=E:\FILES\STATEMENTS\DAILYSTATEMENTS\20150127\R-956-10103.pdf

点击上面应该下载文件 R-956-10103.pdf

任何帮助将不胜感激

4

2 回答 2

0

看看这个:

//Delegate
$(document).delegate(".selector", "iggridcellclick", function (evt, ui) {
    //return cell html element in the DOM
    ui.cellElement;
    //return row index
    ui.rowIndex;
    //return row key
    ui.rowKey;
    //return col index
    ui.colIndex;
    //return col key
    ui.colKey;
    //return reference to igGrid
    ui.owner;
});
 
//Initialize
$(".selector").igGrid({
    cellClick: function(evt, ui) {...}
});

来自: http ://help.infragistics.com/jQuery/2014.2/ 然后转到“事件”选项卡

于 2015-02-03T09:54:02.327 回答
0

该文件应该可以通过网络访问,所以我想它实际上不是一个物理位置,例如E://etc...,而是类似http://file.location/filename.pdf. 因此,如果该位置是可访问的,那么数据源是携带字符串href=http://file.location/filename.pdf还是仅携带位置?我猜是第二个。因此,您可以使用列模板来呈现锚点:

{
    headerText: "Statement", 
    key:"Statement", 
    dataType: "string",
    template: "<a href='${Statement}'>Download</a>"
}

我注意到别的东西。您无需使用dataRendered即可将 CSS 应用于 igGrid 标头。您可以为此使用 CSS:

<style>
    ui-iggrid tr th {
        text-align: center;
    }
</style>
于 2015-02-03T14:57:28.680 回答