问题描述
我在js中用dwr返回一个list集合,然后怎样把这个集合显示成列表的形式,这个列表中有文本框。(见附近)js代码://返回步骤模板明细function callbackStepTemplateDetail (StepTemplateDetail) { // Delete all the rows except for the "pattern" row dwr.util.removeAllRows("stepbody", {filter:function (tr) { return (tr.id != "pattern"); }}); // Create a new set cloned from the pattern row var stepTemplateDetail, stepId; for (var i = 0; i < StepTemplateDetail.length; i++) { stepTemplateDetail = StepTemplateDetail[i]; stepId = stepTemplateDetail.stepId; dwr.util.cloneNode("pattern", {idSuffix:stepId}); dwr.util.setValue("stepId" +stepId, stepTemplateDetail.stepId); dwr.util.setValue("tableCode" + stepId, stepTemplateDetail.code); dwr.util.setValue("tableType" + stepId, stepTemplateDetail.category); dwr.util.setValue("tableProduct" + stepId, stepTemplateDetail.producer); dwr.util.setValue("tableConsume" + stepId, stepTemplateDetail.consumer); dwr.util.setValue("tableStartendtime" + stepId, stepTemplateDetail.startTime+"/"+stepTemplateDetail.endTime); dwr.util.setValue("tableAbstract" + stepId, stepTemplateDetail.abstractDesc); dwr.util.setValue("tableStatus" + stepId, stepTemplateDetail.statusName); // $$("pattern" +stepId).style.display = ""; // officially we should use table-row, but IE prefers "" for some reason jobCache[stepId] = stepTemplateDetail; } jsp页面: <tbody id="stepbody" class="tableBody"> <tr id="pattern" > <td> <input type="text" name="stepId"/> </td> <td> <span id="tableCode"></span> </td> <td> <span id="tableType"></span> </td> <td> <span id="tableProduct"></span> </td> <td> <span id="tableConsume"></span> </td> <td> <span id="tableStartendtime"></span> </td> <td> <span id="tableAbstract"></span> </td> <td> <span id="tableStatus"></span> </td> </tr> </tbody>
解决方案
DWR 返回list 之前做了一个demo ,列表中只是没有文本框,可以自己修改下就OK了。这是那个连接:http://caizi12.iteye.com/blog/652185
解决方案二:
如果dwr返回的是一个list最好让dwr返回一个mapmap.put("list", list);然后再处理。页面这块,如果你是用模版的话,直接解析list再送入模版如果你是用json的话,把list在服务器端变成json,然后送入form就好了