提交struts2表单后如何在网格上加载json结果 [英] how to load json result on grid after struts2 form submission

查看:77
本文介绍了提交struts2表单后如何在网格上加载json结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格,它在页面加载时显示数据,还有一个表单,在提交时从datepicker获取变量,最后调用一个动作.我希望将新的json结果加载到上方的网格上,但相反,我在空白页面上获取了json对象元素 ({{"JSON":"SUCCESS","endDate":"28/03/2012","listOfLogs":[{"date":"27-03-2012" ...等)

I have a grid which displays data on page load, and also a form that on submit gets the variables from datepicker and finally calls an action. I want the new json result to load on grid above but instead of that i get the json object elements on a blank page ({"JSON":"SUCCESS","endDate":"28/03/2012","listOfLogs":[{"date":"27-03-2012"... etc.)

这是我的代码:

<s:url id="getCurrentDateLogs" action="getCurrentDateLogs"/>

<sjg:grid
    id="getLogs"
    dataType="json"
    href="%{getCurrentDateLogs}"
    gridModel="listOfLogs"
    onSelectRowTopics="rowselect"
    loadonce="true"  
    >
    <sjg:gridColumn name="userid" index="userid" title="User ID" sortable="true" align="center"/>
    <sjg:gridColumn name="username" index="username" title="Username" sortable="true"/>
    <sjg:gridColumn name="logaction" index="logaction" width="600" title="Action" sortable="true"/>
    <sjg:gridColumn name="date" index="date" title="Date" sortable="true" sorttype="date" align="center"/>
    <sjg:gridColumn name="time" index="time" title="Time" sortable="true" sorttype="time" align="center"/>     
</sjg:grid>

<s:form action="getLogsByDates" id="form2"  theme="simple" cssClass="yform">
    <table class="">
        <tr><td>from:</td>
            <td><sj:datepicker value="yesterday" id="from" name="startDate" displayFormat="dd/mm/yy" label="from" /></td>
        </tr>
        <tr><td>to:</td> 
            <td><sj:datepicker value="today" id="to" name="endDate" displayFormat="dd/mm/yy" label="to" /></td>
        </tr>
        <tr><td colspan="2">
        <sj:submit
            value="Search" 
            button="true"
            indicator="indicator"
            />
        </td></tr>
    </table>
</s:form>

我正在使用以下库: struts2 2.3.1.2 struts2-jquery 3.3.0 struts2-jquery-grid-plugin 3.3.0

i am using the following libs: struts2 2.3.1.2 struts2-jquery 3.3.0 struts2-jquery-grid-plugin 3.3.0

有什么建议吗? 谢谢!

Any suggestions? Thank you!

推荐答案

至少,您的sj:submit应该设置属性target ="getLogs".不过,您可能还缺少其他东西.

At the very least, your sj:submit should set the attribute targets="getLogs". You may also be missing other things though.

这篇关于提交struts2表单后如何在网格上加载json结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆