我有一个绑定到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
任何帮助都会得到应用
答案 0 :(得分: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/ 然后转到“事件”标签
答案 1 :(得分: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>