Struts动作类和JQuery对话框中的JQGrid数据

时间:2013-11-25 07:37:11

标签: jquery jqgrid struts2

我是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>

我怀疑是否需要向动作类发送RollNo以在对话框中显示网格。

当用户点击链接时,操作转到someAction并从数据库获取数据并在对话框中显示为JQGrid格式..我可以管理以打开dailog框但是不知道如何将RollNo发送给action类以及如何在Action类中映射它。

当用户点击链接时,dailog将设置为true。如果有任何进一步的说明,请告诉我。

1 个答案:

答案 0 :(得分:0)

不知怎的,我设法使用自定义格式链接来解决这个问题..

function link(cellvalue,options,rowObject)
   {
       return "<a href='myAction?linkCode"+rowObject['rollno']+"' > "+cellvalue+"</a>";
    }

我为linkCode参数创建了getter和setter ..我能够获得该值..在动作类中..