可以使用部分视图来进行 Ajax 项目更新吗?

发布于 2024-08-13 12:07:24 字数 1866 浏览 10 评论 0原文

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

每行的一部分可以加载一个带有提交按钮的子表项吗?

示例表:

<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 列是一个表单,以便用户可以设置值或根据以前的值更新它们。

我能否以某种方式在单个 Ajax 表单中每行包含 3 个 TD 项,并将 codeId 作为隐藏值嵌入?我的强类型视图会继承什么?外层将继承 IEnumerable,部分视图将继承 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>

I have a table built from a list of defect codes.

Can part of each row load a sub-table item complete with submit buttons?

Sample table:

<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>

Where the first 2 columns are populated from the lookup table, and the next 3 columns are a form so the user can set the values or update them from previous values.

Can I somehow have 3 TD items per row an individual Ajax form with the codeId embedded as a hidden value? What would my strongly typed view(s) inherit? the outer layer would inherit IEnumerable<DefectDTO>, and the partial views would inherit the AssessmentDTO type?

Here's the actual table I'm trying to get to function:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2024-08-20 12:07:24
<% 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 并获得比表格上显示的更多的价值。

<% 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>

its just solves ur hidden value! problem..

u dont need to put it into a TD cause u want it to be hidden so it will still get the value for u but will not be shown in form or in table or in view.. that way u can keep 3 TD and get more value than the shown on form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文