0

嗨,我有一个名为 taskReminder 的页面,它呈现两个模板:1 个用于任务,1 个用于提醒。该任务有复选框,当勾选时,它应该重新填充/更新任务列表。一切正常,但我似乎无法理解为什么任务框架会更新并在其中显示整个页面。总结:整个页面有一个任务框架,其中还显示了整个页面。(就像 inception 一样!)我重新设计了 html,重新评估了我的远程功能,我还尝试在提醒框架内放置一个差异复选框 - 当勾选,它会更新任务框架内的提醒列表,其中包含整个页面,而不是他自己的框架列表。

首次加载时,未单击复选框 - 显示正常 在第一次加载

当复选框被勾选并且任务框架向下滚动时,请注意提醒框架也在那里或整个页面

为什么会这样?我的代码:对于任务提醒持有人

   <%@ page import="com.irondata.icmgrails.constants.*" %>

<html>
  <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <style type="text/css">
            body {background-color:#EEF2F7;}
        </style>
        <script type="text/javascript" language="javascript" src="${resource(dir:'js',file:'icmutilities.js')}"></script>
    </head>
   <body role="main">
   <g:form>
        <g:hiddenField name="caseId" value="${cmCaseInstance?.id}" /> 

        <div class="body" role="article">
            <h1>Tasks and Reminders</h1>
            <br />
            <br />
            <div id="tasks">
                    <div class="summary">
                        <div class="summaryHeader">
                            <div class="summaryHeaderLeft">Tasks</div>
                            <div class="summaryHeaderCenter">&nbsp;</div>
                            <div class="summaryHeaderRight">&nbsp;</div>
                        </div>

                         <div class="gadgetShort">
                            <div>
                                <g:checkBox name='test' onclick="${remoteFunction(action:'workCategory', params:'\'completed=\'+ this.checked + \'&caseId=\' + caseId.value', update:[success:'divTasks', failure:'divTasks']) }" value="${false}"/>
                            </div>
                            <div id="divTasks">
                                <g:render template="taskList" model="['taskInstanceList': taskInstanceList, 'taskInstanceTotal': taskInstanceTotal, 'cmCaseInstance':cmCaseInstance]"/>
                            </div>   
                         </div>
                    </div>
            </div>
            <div id="reminders">
                    <div class="summary">
                        <div class="summaryHeader">
                            <div class="summaryHeaderLeft">Reminders</div>
                            <div class="summaryHeaderCenter">&nbsp;</div>
                            <div class="summaryHeaderRight">&nbsp;</div>
                        </div>

                         <div class="gadgetShort">
                            <div>
                                <span class="gadgetName">Reminder List</span><span class="gadgetNumber">${taskInstanceTotal}</span>
                            </div>
                            <div id="divReminders">
                                <g:render template="reminderList" model="['reminderList': reminders, 'reminderListTotal': reminderCount]"/>
                            </div>   
                         </div>
                    </div>
            </div>
        </div>
   </g:form>



   </body>
</html>

任务列表和提醒列表完全一样,所以我没有放提醒列表的代码。

<span class="gadgetName">Task List</span><span class="gadgetNumber">${taskInstanceTotal}</span>

            <table cellspacing="0" cellpadding="0" id="tasksTableGrails" class="icmSortableTable" summary="Tasks" >
                <thead>
                    <tr>

                        <g:sortableColumn scope="col" property="activityDescrip" title="${message(code: 'taskByCase.description.label', default: 'Description')}" params="${flash}" />

                    </tr>
                </thead>                                              
                <g:each in="${taskInstanceList}" status="i" var="taskInstance">
                    <tr class="${(i % 2) == 0 ? '' : 'altRowColor'}">

                        <td>${fieldValue(bean: taskInstance, field: "activityTypeIdActivityType.activityDescrip")}</td>

                </g:each>          
            </table>

这是我背后的代码:

def workCategory = {


        def isCompletedTaskIncluded


        flash.employeeId = params.employeeId
        flash.caseId = params.caseId

        def cmCaseInstance = CmCase.get(params.caseId as Long)
        def employee = employeeService.getUserEmployee(session.currentUser.id)

        def criteria = Task.createCriteria()
        def query = {

            eq ("cmCaseIdCmCase", cmCaseInstance)
            or {
                eq ("fromEmplIdEmployee", Employee.get(employee.id))
                eq ("toEmplIdEmployee", Employee.get(employee.id))
            }
            if(params.completed=="false")
                isNull("actCompDate")


        }

        def taskInstanceList = criteria.list(query)

        def reminders = Reminder.createCriteria().list() {
            createAlias("cmCaseIdCmCase", "cmCase")
            isNull("cmCase.closedDate")
            eq('employeeIdEmployee', employee)
            eq("cmCaseIdCmCase", cmCaseInstance)


        }

        def taskCount = taskInstanceList.size()
        def reminderCount = reminders.size()
        render(view: "taskReminder", model: [taskInstanceList: taskInstanceList, taskInstanceTotal:  taskCount, reminderList: reminders, reminderListTotal: reminderCount, cmCaseInstance:cmCaseInstance])

    }
4

1 回答 1

1

编辑您的控制器:

render(view: "taskReminder", model: [taskInstanceList: taskInstanceList, taskInstanceTotal:  taskCount, reminderList: reminders, reminderListTotal: reminderCount, cmCaseInstance:cmCaseInstance])

to(修复模板路径和任务模板的名称):

if(request.xhr){
   render(template: '/***templatePath***/task.gsp', model: [taskInstanceList: taskInstanceList, taskInstanceTotal:  taskCount, reminderList: reminders, reminderListTotal: reminderCount, cmCaseInstance:cmCaseInstance])
   return
}

render(view: "taskReminder", model: [taskInstanceList: taskInstanceList, taskInstanceTotal:  taskCount, reminderList: reminders, reminderListTotal: reminderCount, cmCaseInstance:cmCaseInstance])
于 2012-10-01T17:37:25.890 回答