对话框中的MVC4 WebGrid在IE中挂起,在Chrome中没有分页

时间:2014-01-30 17:16:38

标签: asp.net-mvc-4 webgrid

MVC4:我是使用WebCrid和MVC的新手。下面的代码在对话框中生成WebGrid,但是分页在Chrome(显示空白页面)和IE中显示不起作用:显示WebGrid的对话框,但IE挂起(似乎正在做某事然后挂起,甚至没有机会尝试分页)。 我的代码出了什么问题? 谢谢 HomeController.cs

public ActionResult MyReport (int id)       // get here on click in SelectList
{ 
      List<MyLocation> myl = MyLocation.GetAllLocations(31);  // static method in MyLocation model
      return View(myl);
}


public ActionResult MyLocationDetails (int id)
{ 
        LocationDetails ld = new LocationDetails();
        List<LocationDetails> model = ld.GetTestLocationDetails();  //model has 20 records
        return PartialView(model);    // MyLocationDetails partial view to be displayed in Dialog
}

MyReport.cshtml应该显示对话框的视图

@model IEnumerable<MyLocation>  

@Html.ActionLink("Location Details", "MyLocationDetails", null, new { id = 234 }, new { @class = "LocDetails" })

<div id="LocDetails-dialog"></div>

<script type="text/javascript">
    $(function () {
        $('#LocDetails-dialog ').dialog({
            autoOpen: false,
            width: 400,
            resizable: false,
            modal: true
        });

        $('.LocDetails').click(function() {
            $('#LocDetails-dialog ').load(this.href, function() {
                $(this).dialog('open');
            });
            return false;
        });
    });
</script>

MyLocationDetails.cshtml

@model List

<div>
@if (Model != null)
{
    if (Model.Count != 0)
    {
        <div id="divLocDetails">
            @{WebGrid grid = new WebGrid(source: Model,
                               rowsPerPage: 5,
                               canPage: true
                               );
              grid.SortDirection = SortDirection.Ascending;
            }

            @grid.GetHtml(
                    htmlAttributes: new { id = "LocDetails" },                           
                        mode: WebGridPagerModes.All,
                        firstText: "First",
                        previousText: "Prev",
                        nextText: "Next",
                        lastText: "Last",                             
                        columns: new[] {  
                            grid.Column("city", header: "City",  canSort: true), 
                            grid.Column("country", header: "Country",  canSort: false)                 

                    }                      
                    )
        </div>

    }
    else
    {
        <label>No results</label>
    }
}
</div>

0 个答案:

没有答案