easyui 查看隐藏字段的值

通过列表查看按钮查看隐藏信息,需要用到索引值  index, event是为了点击查看按钮不会选中这行信息,有点绕口,显示详细信息是弹出一个dialog窗口,代码如下:

function look(index,event){
           event.stopPropagation();
           event.preventDefault();
           var row = $('#preHandleSample').datagrid('getData').rows[index];
            if(typeof(row.taksRemark) =='undefined'){
                row.taksRemark="";
            }
            if(typeof(row.checkerRemark) == 'undefined'){
                row.checkerRemark="";
            }
           $("#lookRemark").dialog({
                title:'查看备注及其他说明',
                href:base + "/sample-check-task/pre-handle/loadRemark.action?taksRemark="+row.taksRemark
                        +"&checkerRemark="+row.checkerRemark,
                width: 700,   
                height: 500,   
                closed: false,   
                modal: true,
            });
       }

首先通过当前索引调用getDate返回当前选中行的数据,然后取得隐藏字段的信息,typeof 判断所取得的隐藏字段的类型,为什么要判断呢,因为如果我们所取得的字段没有信息,那么他的类型是 undefined,所以我这里加了typeof 用来判断,如果没有这种情况可以不加,看情况而定,我是用的struts2,后台跳一个方法返回到前台所弹出的dialog窗口。

action类:

public String loadRemark(){
        Sample sample=new Sample();
        sample.setRemark(taksRemark);
        sample.setCheckerRemark(checkerRemark);
        HttpServletRequest request = ServletActionContext.getRequest();
        request.setAttribute("sample", sample);
        return SUCCESS;
    }

我是将这2 个字段属性封装在实体类里面放在request里,返回到前台的,也可以直接返回实体类。注意:字段属性要对应,一定要有set,get 方法。
jsp页面:
  <form id="lookRemarker" method="post">
<table class="input" style="margin-left: auto; margin-right: auto; margin-top: 5px; width: 98%;">
<tbody>
<tr>
<th style="vertical-align:top">备注</th>
<td>
<textarea id="remark" style="width:98%;height:170px;resize: none;font-size:14px;" disabled="disabled">
<s:property value="#request.sample.remark"/>
</textarea></td>
</tr>
<tr>
<th style="vertical-align:top">其他说明</th>
<td>
<textarea id="checkerRemark" style="width:98%;height:170px;resize: none;font-size:14px;" disabled="disabled">
<s:property value="#request.sample.checkerRemark"/>
</textarea></td>
</tr>
</tbody>
</table>
</form>

猜你喜欢

转载自1147959444.iteye.com/blog/2263427