使用jquery+;从局部视图添加新行;Ajax MVC 4.NET

使用jquery+;从局部视图添加新行;Ajax MVC 4.NET,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我有一个局部视图,它定义了表的一行,如下所示: @model CarpetApp.Models.OrderDetails <script src="~/Scripts/jquery-1.7.1.min.js"></script> <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.

我有一个局部视图,它定义了表的一行,如下所示:

@model CarpetApp.Models.OrderDetails
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

@using (Html.BeginCollectionItem("OrderDetails"))
{
    <tr>
        <td>@Html.EditorFor(model => model.RunningNO)</td>
        <td>@Html.EditorFor(model => model.ProjectReference)</td>
        <td>@Html.DropDownListFor(model => model.DesignId, Model.design)</td>
        <td>Quality Dropdown List</td>
        <td>@Html.ListBoxFor(model => model.SelectBackGround, Model.BackGround)</td>
        <td>@Html.ListBoxFor(model => model.SelectedMotif, Model.Motif)</td>
        <td>@Html.DropDownListFor(model => model.measurement, Model.mesurements)</td>
        <td>@Html.EditorFor(model => model.WidthIntPart)</td>
        <td>@Html.EditorFor(model => model.WidthDecPart)</td>
        <td>@Html.EditorFor(model => model.LengthInt)</td>
        <td>@Html.EditorFor(model => model.LengthDec)</td>
        <td>@Html.EditorFor(model => model.Area)</td>
        <td>@Html.EditorFor(model => model.Remark)</td>
    </tr>
}
但是,问题在于,部分视图是通过Ajax调用返回的,但与调用Ajax函数的视图中定义的表列不一致。相反,结果只加载到单个列中

我可以类似地加载ajax本身预定义的html,web上也有各种解决方案。但是,我无法加载上面部分视图中定义的行。特别是使用

@Html.Action("AddOrder")
但是,它可以按预期工作


非常感谢您的帮助。

我的项目也遇到了同样的问题。在部分示例中,尝试将Begin集合放入


@使用(Html.BeginCollectionItem(“OrderDetails”))
{
@EditorFor(model=>model.RunningNO)
@EditorFor(model=>model.ProjectReference)
@DropDownListFor(model=>model.DesignId,model.design)
质量下拉列表
@Html.ListBoxFor(model=>model.SelectBackGround,model.BackGround)
@Html.ListBoxFor(model=>model.SelectedMotif,model.Motif)
@DropDownListFor(model=>model.measurement,model.measurements)
@EditorFor(model=>model.WidthIntPart)
@EditorFor(model=>model.WidthDecPart)
@EditorFor(model=>model.LengthInt)
@EditorFor(model=>model.LengthDec)
@EditorFor(model=>model.Area)
@Html.EditorFor(model=>model.Remark)}
祝你好运

         $(function () {
             $("#addAnother").click(function () {
                 event.preventDefault();
                 $.get('/Order/AddOrder', function (template) {
                     $("#tabletab").append(template);
                 });
             });
         });
@Html.Action("AddOrder")
<tr>
    @using (Html.BeginCollectionItem("OrderDetails"))
   {
    <td>@Html.EditorFor(model => model.RunningNO)</td>
    <td>@Html.EditorFor(model => model.ProjectReference)</td>
    <td>@Html.DropDownListFor(model => model.DesignId, Model.design)</td>
    <td>Quality Dropdown List</td>
    <td>@Html.ListBoxFor(model => model.SelectBackGround, Model.BackGround)</td>
    <td>@Html.ListBoxFor(model => model.SelectedMotif, Model.Motif)</td>
    <td>@Html.DropDownListFor(model => model.measurement, Model.mesurements)</td>         
    <td>@Html.EditorFor(model => model.WidthIntPart)</td>
    <td>@Html.EditorFor(model => model.WidthDecPart)</td>
    <td>@Html.EditorFor(model => model.LengthInt)</td>
    <td>@Html.EditorFor(model => model.LengthDec)</td>
    <td>@Html.EditorFor(model => model.Area)</td>
    <td>@Html.EditorFor(model => model.Remark)</td>}
</tr>