【问题标题】:Ext.net How to set total page for pagingtoolbar?Ext.net 如何设置分页工具栏的总页数?
【发布时间】:2012-06-04 03:51:59
【问题描述】:

我有一个数据集,在数据集中我有两个功能: GetDataMenuPagin(@PageIndex, @PageSize) SP_GetCountMenuDataPagin() 我从具有 1500 条记录的名为“菜单”的表中获取数据。我将页面大小设置为 10,因此总页面必须为 150 页。但是我如何设置分页工具栏的总数?

这是我的对象数据源和存储,我使用数据集:

<asp:ObjectDataSource ID="MenuDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetDataMenuPagin" EnablePaging="false" 
        TypeName="dsHorizonTableAdapters.MenuTableAdapter" OnUpdating="MenuDataSourceUpdating"
        DataObjectTypeName="System.Guid" DeleteMethod="Delete" InsertMethod="Insert"
        OnSelecting="MenuDataSource_Selecting">
        <InsertParameters>
            <asp:Parameter DbType="Guid" Name="Id" />
            <asp:Parameter DbType="Guid" Name="ParentMenuId" />
            <asp:Parameter DbType="Guid" Name="PageId" />
            <asp:Parameter Name="Criteria" Type="String" />
            <asp:Parameter Name="Display" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="MenuURL" Type="String" />
            <asp:Parameter Name="Sort" Type="String" />
            <asp:Parameter Name="IsActive" Type="Boolean" />
            <asp:Parameter Name="UpdateDate" Type="DateTime" />
            <asp:Parameter Name="UpdateUser" Type="String" />
            <asp:Parameter DbType="Guid" Name="MethodId" />
            <asp:Parameter Name="Image" Type="String" />
            <asp:Parameter DbType="Guid" Name="ProgramId" />
            <asp:Parameter DbType="Guid" Name="StatusId" />
        </InsertParameters>
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="PageIndex" Type="Int32" />
            <asp:Parameter DefaultValue="10" Name="PageSize" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <ext:Store ID="MenuStore" runat="server" DataSourceID="MenuDataSource" AutoDataBind="false"
        AutoLoad="false" onrefreshdata="MenuStore_RefreshData">
        <Reader>
            <ext:JsonReader IDProperty="Id" AutoDataBind="True">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="ParentMenuId" />
                    <ext:RecordField Name="PageId" />
                    <ext:RecordField Name="Criteria" />
                    <ext:RecordField Name="Display" />
                    <ext:RecordField Name="Description" />
                    <ext:RecordField Name="MenuURL" />
                    <ext:RecordField Name="IsActive" DefaultValue="true" />
                    <ext:RecordField Name="Sort" DefaultValue="0" />
                    <ext:RecordField Name="UpdateDate" Type="Date" />
                    <ext:RecordField Name="UpdateUser" />
                    <ext:RecordField Name="ParentMenuDisplay" />
                    <ext:RecordField Name="PageDisplay" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <Listeners>
            <LoadException Handler="Ext.Msg.Alert('Column - Load failed', e.message || e )" />
            <CommitFailed Handler="Ext.Msg.Alert('Column - Commit failed', 'Reason: ' + msg)" />
            <SaveException Handler="Ext.Msg.Alert('Column - Save failed', e.message || e)" />
            <CommitDone Handler="Ext.Msg.Alert('Column - Commit', 'The data successfully saved');" />
        </Listeners>
    </ext:Store>

【问题讨论】:

    标签: asp.net sql ext.net


    【解决方案1】:

    所以我有以下内容,我使用的是 VB,但我确信你可以将其转换为 C#

    在“SelectParameters”中,我还有一个叫做“TotalPages”的,看起来像这样

    <ext:Parameter Name="TotalPages" Type="Int32" Direction="Output" />
    

    在您的 GetDataMenuPagin 方法中应该看起来类似于...

    Public Shared Function GetDataMenduPagin(ByVal  PageIndex As Int32, ByVal PageSize as Int32, ByRef TotalPagesas Int32) As List(Of xxxxx)
    Dim res = (from i in db.my_table _
               Select i).Skip(PageIndex).Take(PageSize)
    
    TotalPages = res.Count()
    
    Return res.ToList()
    End Function 
    

    如您所见,我们将 TotalPages 设置为输出,通过它我们可以绑定 选择方法中的数字,只要您指定它是一个输出参数。

    我在 C# 的某个地方看到过这个例子,但是我不记得在哪里了。今天晚些时候我会仔细检查一下

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 1970-01-01
      • 1970-01-01
      • 2011-05-04
      • 1970-01-01
      相关资源
      最近更新 更多