我正在尝试在单元格内生成链接:
单元格的源代码如下:
android:paddingLeft="3dp"
android:paddingRight="3dp"
使用上面版本的Jqgrid编写的源代码有效,但是这个新版本没有用,我在文档中找不到任何内容。
答案 0 :(得分:0)
我使用自定义格式化程序,因为它允许任何类型的链接。见下文:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Your page title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/css/ui.jqgrid.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/jquery.jqgrid.min.js"></script>
<script>
//<![CDATA[
function htmlTest() {
htmlTest.prototype.display = function(){
$("#grid").jqGrid({
colModel: [
{ name: "firstName" },
{ name: "lastName", formatter:this.htmlFormatter}
],
data: [
{ id: 10, firstName: "Angela", lastName: "Merkel" },
{ id: 20, firstName: "Vladimir", lastName: "Putin" },
{ id: 30, firstName: "David", lastName: "Cameron" },
{ id: 40, firstName: "Barack", lastName: "Obama" },
{ id: 50, firstName: "François", lastName: "Hollande" }
]
}
);
};
htmlTest.prototype.htmlFormatter = function( cellvalue, options, rowObject ) {
var id = options.rowId;
var something = "blabla";
return "<a href='http://someurl.com?id=" + id + "&something=" + something + "' target='yourTargetWindow'>" + cellvalue + "</a>";
};
};
$(document).ready(function () {
var myTest = new htmlTest();
myTest.display();
});
//]]>
</script>
</head>
<body>
<table id="grid"></table>
</body>
</html>