1

我有一个在页面加载时加载数据的网格。我还有一个在提交时正确调用操作的表单,但它不会在我的网格上加载新数据。

列表在我的网格模型中正确获取并正确设置来自我的 Action 类,但是在返回 SUCCESS 时,它只是以这种形式返回数据(见下面的输出)......

{"authFirstname":null,"authLastname":null,"bookDetailsobj":null,"bookTitile":null,"get":{"authFirstname":null,"authLastname":null,"bookTitile":null,"coverId":null,"createdDate":null,"createrId":null,"description":null,"editionId":null,"editionYear":null,"id":null,"img1":null,"img2":null,"isbn":null,"languageId":null,"locationId":null,"price":null,"publisherName":null,"quantity":null,"remarks":null,"subjectId":null,"updateId":null,"updatedDate":null,"videoUrl":null},"gridModel":[{"authFirstname":"234234","authLastname":"2323423","bookTitile":"23324234234","coverId":"soft cover","description":"243234","editionId":"General Edition","editionYear":"234234","id":42,"img1":"","img2":"","isbn":"324234","languageId":"English","locationId":"as","price":2.34234E7,"publisherName":"234234","quantity":234234,"remarks":"","subjectId":"General Fiction","videoUrl":""},{"authFirstname":"2423","authLastname":"23423","bookTitile":"asdfsdaf","coverId":"soft cover","description":"","editionId":"General Edition","editionYear":"2","id":39,"img1":"","img2":"","isbn":"2","languageId":"English","locationId":"as","price":234.0,"publisherName":"2","quantity":2,"remarks":"","subjectId":"General Fiction","videoUrl":""},{"authFirstname":"3","authLastname":"3","bookTitile":"232","coverId":"soft cover","description":"","editionId":"General"} 

我的jsp代码:

         <sjg:grid
                id="getLogs"
                dataType="json"
                href="%{getCurrentDateLogs}"
                gridModel="listOfLogs"
                onSelectRowTopics="rowselect"
                loadonce="true"
                reloadTopics="reloadGrid"
                formIds="form2"
            >
            <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"
                        onClickTopics="reloadGrid"
                    indicator="indicator"
                    />
                </td></tr>
            </table>
         </s:form>

struts.xml

 <action name="getLogsByDates" class="v.esoft.actions.bookdetails.BookdetailsAction" >
            <result name="success"  type="json"/>
            <result name="login" type="redirect"> /index.jsp </result>
   </action> 

** 我不知道为什么我的输出没有显示在我的 jquery 网格中。请帮我**

4

3 回答 3

2

我想这就是你需要的:

  1. 不要使用 sj:submit 标记,而是使用带有指向 GridReloadTopics 的 onClickTopics 的 sj:a 标记。

  2. 然后当单击 sj:a 时,网格会重新加载,将表单提交给网格的 href 属性中定义的动作。

  3. 此操作必须生成将填充网格的 JSON。

您尚未在问题中显示操作“getCurrentDateLogs”。所以这是必须返回填充网格的 json 结果的操作。

此外,您必须考虑网格数据如何受到表单字段的影响,所以很容易

  1. 网格将所有表单字段提交给 href 中提到的操作,因此您必须为该操作的每个表单字段设置一个 getter 和 setter。

  2. 除了其他正常的网格属性,现在您将收到其他表单属性,这些属性基于您将填充 gridModel 的值。

如果您仍然不明白,请告诉我。

于 2012-11-04T17:27:13.177 回答
0

我在提交表单后找到了两个网格,一个是旧的,第二个是我的搜索网格,它还包括整个页面

<sj:a  href="%{form}" targets="result" indicator="indicator" button="true" buttonIcon="ui-icon-refresh"/>
于 2013-03-12T13:02:46.773 回答
0

这种方式行不通。尝试做以下事情:

  1. 使一个动作返回一个页面,而不是 json

    <result name="success">page_with_the_grid.jsp</result>
    
  2. 在页面上page_with_the_grid.jsp,使用s:url标记来映射您的 json 结果:

    <s:url var="jsonUrl" action="jsonAction"/>
    
  3. 在您的sj:grid, 用于href="%{jsonUrl}"将您的数据填充到网格中。

如果您直接调用返回的操作JSON,您肯定会得到一个 json 结果,这是您的“奇怪”输出。

于 2012-11-04T14:10:55.363 回答