代码之家  ›  专栏  ›  技术社区  ›  Maslow

局部视图可以用来更新Ajax项目吗?

  •  1
  • Maslow  · 技术社区  · 15 年前

    我有一个由缺陷代码列表构建的表。

    每行的一部分是否可以加载一个子表项,该子表项包含提交按钮?

    样品表:

    <table><tr>
    <th>Code</th><th>Description</th>
    <th>Impact to your customers</th>
    <th>Impact to your associates</th>
    <th>Save</th>
    <th>Save Errors</th></tr>
    

    其中前2列是从查找表填充的,后3列是一个窗体,因此用户可以设置值或从以前的值更新它们。

    我能要3个吗 TD 每行项一个单独的Ajax表单,其中codeId作为隐藏值嵌入?我的强类型视图将继承什么?外层将继承 IEnumerable<DefectDTO> ,局部视图将继承 AssessmentDTO 类型?

    下面是我试图使用的实际表:

    <table>
        <tr>
    
            <th>
                Code
            </th>
            <th>
                Description
            </th>
            <th>
                Document
            </th>
            <th>
                Customer Contact Required for Resolution
            </th>
            <th>
                AssociateSeverity
            </th>
            <th>
                ShareholderSeverity
            </th>
            <th>
                CustomerSeverity
            </th>
            <th>
                RegulatorySeverity
            </th>
            <th>
                RootCause
            </th>
            <th>
                Investor Requirements*
            </th>
        </tr>
    
    <% foreach (var item in Model.DefectCodes) { %>
    
        <tr>
            <% using (Ajax.BeginForm("Create", new AjaxOptions() ))
               {%>
            <td>
                <%= Html.Encode(item.Code)%>
            </td>
            <td>
                <%= Html.Encode(item.Description)%>
            </td>
            <%  Html.RenderPartial("Create",null, ViewData); %><!-- This is where the form is -->
            <% } %>
        </tr>
    
    <% } %>
    
    </table>
    
    1 回复  |  直到 15 年前
        1
  •  0
  •   Berker Yüceer    13 年前
    <% foreach (var item in Model.DefectCodes) { %>
    
        <tr>
            <% using (Ajax.BeginForm("Create", new AjaxOptions() ))
               {%>
    
            <!--should be easy like this!--><!--ur codeid here-->
            <%=Html.HiddenFor(modelItem => item.codeid)%> 
    
            <td>
                <%= Html.Encode(item.Code)%>
            </td>
            <td>
                <%= Html.Encode(item.Description)%>
            </td>
            <%  Html.RenderPartial("Create",null, ViewData); %><!-- This is where the form is -->
            <% } %>
        </tr>
    
    <% } %>
    
    </table>
    

    它只是解决你隐藏的价值!问题。。

    你不需要把它放进一个 TD 因为你希望它被隐藏,所以它仍然会得到你的值,但不会显示在窗体、表或视图中。。这样你就可以保留3个 TD公司 得到比表上显示的更多的值。