2

部分ビューでページネーション機能を備えたテーブルソーターを使用しています。ページの更新を防ぐために、ビュー ページで ajax を使用して部分ビューが読み込まれます。tablesorter のみを適用すると、正常に動作します。しかし、テーブルソーターでページネーションを適用すると、適切な出力が得られません。

ページにドロップダウンリストがあり、ドロップダウンリストで値を選択すると、データが完全にロードされ、並べ替えとページネーションが次のように正常に機能します。

ここに画像の説明を入力

しかし、2回目にドロップダウンリストから別の値を選択します。データが表示されません。

ここに画像の説明を入力

ページネーションなしでテーブルソーターのみを使用する場合、ドロップダウンで異なる値を選択するたびに正常に動作します。

この理由は何ですか?

これは私のビューページのコードです:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Search MDLNoWise
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<fieldset>
<legend>Search by MDLNo</legend> 
<div id="search">
<br /><br />
Select MDLNo
<%: 
Html.DropDownListFor(
      model => model.Request_For_Id, 
      ViewData["MDLno"] as SelectList, "--Select--", new {id ="Request_For_Id" })

%>
<br /><br />

<div id="viewlist"> 
</div>
</div>
</fieldset>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../../Content/Styles/blue.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function () {

        $('#Request_For_Id').change(function () {
            var mdlno = document.getElementById("Request_For_Id").value;


            $.ajax({
                url: '/Search/MDLNoDataList/',
                type: "POST",
                data: {
                    id: mdlno
                },
                dataType: "html",
                success: function (data) {
                    $("#viewlist").html(data);
                },
                error: function () {
                    alert("No Records Found");
                    //$("#viewlist").html('No Records Found');
                }
            });

        });
    });
</script>
</asp:Content>

これは、ページネーションで tablesorter を使用する私の部分的なビューです。

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>>" %>
<%--<script src="@Url.Content("../../Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("../../Scripts/jquery.tablesorter.js")" type="text/javascript"></script>
    <script src="@Url.Content("../../Scripts/jquery.tablesorter.pager.js")" type="text/javascript"></script>--%>
<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.tablesorter.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.tablesorter.pager.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("table.tablesorter").tablesorter()
                              .tablesorterPager({ container: $("#pager"), size: $(".pagesize option:selected").val() });
    });
    </script>
    <div>
<table class="tablesorter">
<thead> 
    <tr>
        <th>
            Request_For_Id
        </th>
        <th>
            Territory
        </th>
        <th>
            Estimated_Amount
        </th>
        <th>
            Actual_Amount
        </th>
        <th>
            Date_Created
        </th>
        <th>
            Compute_CRM_State
        </th>
        <th>
            Compute_Event_Type
        </th>
    </tr>
    </thead> 
    <tbody>
    <% foreach (var item in Model)
       { %>
     <tr>
        <td>
            <%: Html.DisplayFor(modelItem => item.Request_For_Id)%>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.Territory)%>
        </td>

        <td>
            <%: Html.DisplayFor(modelItem => item.Estimated_Amount)%>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.Actual_Amount)%>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.Date_Created)%>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.Compute_CRM_State)%>
        </td>
        <td>
            <%: Html.DisplayFor(modelItem => item.Compute_Event_Type)%>
        </td> 
    </tr>
    <%} %>
    </tbody>

</table>

<div id="pager" style="position: none;">

            <img src="../../Content/images/first.png" class="first" />
            <img src="../../Content/images/prev.png" class="prev" />
            <input type="text" class="pagedisplay" />
            <img src="../../Content/images/next.png" class="next" />
            <img src="../../Content/images/last.png" class="last" />
            <select class="pagesize">
                <option selected="selected" value="1">1</option>
                <option value="10">10</option>
                <option value="20">20</option>
                <option value="30">30</option>
                <option value="40">40</option>
            </select>

        </div>
        </div>
4

0 に答える 0