我是struts2 JQuery网格的新手。我正在使用JQuery网格来生成链接。自定义格式化程序-这是我的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
<%@taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<sj:head jqueryui="true" jquerytheme="redmond" />
<title>gridTest</title>
<link rel="stylesheet" type="text/css" media="screen" href="/plugins/snap/jquery.jqGrid- 4.3.1/css/ui.jqgrid.css" />
<script type="text/javascript">
function formatLink(cellvalue, options, rowObject) {
//$("#employees_details").dialog('open');
//openDialog(employee);
return "<a href='ajaxActionFromJS' >" +cellvalue+ "</a>";
}
function openDialog() {
$("#employees_details").dialog('open');
}
</script>
<body>
<s:url var="remoteurl" action="jsontable"/>
<s:url var="empurl" action="employees-detail" />
<sjg:grid
id="gridtable"
caption="Customer Examples"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rownumbers="true"
width="400"
height="400"
altRows="true"
draggable="true"
editinline="true"
>
<sjg:gridColumn name="name" index="Name" title="Name" sortable="false"/>
<sjg:gridColumn name="check" index="check" title="Check"
sortable="false" formatter="checkbox"
editable="true"
formatoptions="{disabled:'false'}"
edittype="checkbox"
value="name"
timeout="100" />
<sjg:gridColumn name="rollno" index="rollno" title="rollno"
sortable="false"
editable="true"
edittype="text"
formatter="integer"
/>
<sjg:gridColumn
name="name"
index="name"
title="Employee"
align="center"
value="rollno"
formatter="formatLink"
/>
</sjg:grid>
<s:if test="dailog">
<s:url var="dailog" action='ajaxAction1234' />
<sj:dialog
id="employees_details"
title="Employee Details"
closeOnEscape="true"
modal="true"
width="400"
>
<sjg:grid
id="boxTable"
caption="I am Dialog Box"
dataType="json"
href="ajaxAction1234"
pager="true"
gridModel="dailogList"
rownumbers="true"
width="400"
height="400"
altRows="true"
draggable="true"
editinline="true"
>
<sjg:gridColumn name="name" index="Name" title="Name" sortable="false"/>
<sjg:gridColumn name="check" index="check" title="Check"
sortable="false" formatter="checkbox"
editable="true"
edittype="checkbox"
timeout="100" />
<sjg:gridColumn name="rollno" index="rollno" title="rollno"
sortable="false"
editable="true"
edittype="text"
formatter="integer"
/>
</sjg:grid>
</sj:dialog>
</s:if>
<s:submit action="getJSONAction" value="submit" ></s:submit>
</s:form>
</body>
我怀疑我需要向action类发送一个RollNo
才能在对话框中显示网格。
当用户单击链接时,操作将转到someAction
并从DB获取数据,并在对话框中显示为JQGrid格式。我可以打开一个dailog
框,但不知道如何将该RollNo
发送到action,以及如何在Action中映射它。
当用户单击链接时,dailog
将被设置为true。如有任何进一步澄清,请告知我。
发布于 2013-11-27 01:35:59
不知怎么的,我设法用自定义格式链接解决了这个问题。
function link(cellvalue,options,rowObject)
{
return "<a href='myAction?linkCode"+rowObject['rollno']+"' > "+cellvalue+"</a>";
}
我为这个linkCode
参数创建了getter和setter。我能得到那个价值..。在课堂上..。
https://stackoverflow.com/questions/20187029
复制相似问题