Radgrid 的自定义分页不起作用

发布于 2024-12-25 12:19:05 字数 1082 浏览 1 评论 0原文

我在这里查看不同问题的答案,但无法找到我可以使用的东西,我是 RadGrid 的新手,一直使用 GridView,但现在,他们将它们全部更改为 RadGrid,其中之一需要自定义分页,有一个示例此处和我正在尝试使用它,但如果我的数据源是数据集,我不确定该怎么做,请参见下文,

                AdminManager adminMan = new AdminManager();
                DataSet ds = adminMan.GetProducts();

                int startRowIndex = (ShouldApplySortFilterOrGroup()) ?
                   0 : Grid.CurrentPageIndex * Grid.PageSize;


                int maximumRows = (ShouldApplySortFilterOrGroup()) ?
   **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
                     MyBusinessObjectCollection1.SelectCount() : RadGrid1.PageSize;**

                Grid.AllowCustomPaging = !ShouldApplySortFilterOrGroup();

      **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
              RadGrid1.DataSource = MyBusinessObjectCollection1.Select(startRowIndex, maximumRows);**

如您所见,我不确定在使用数据集时如何转换该示例代码。请参阅我注意到的部分“这里不确定如何翻译......”任何帮助将不胜感激。

问候

I was looking at the answers from different questions here but cant get to something that I can use, I am new to the RadGrid stuff had always used GridView but now, they changed them all to RadGrids and one of them needs to have the paging custom, there is an example here and I am trying to use it but i am not sure how to do it if my data source is a data set see below

                AdminManager adminMan = new AdminManager();
                DataSet ds = adminMan.GetProducts();

                int startRowIndex = (ShouldApplySortFilterOrGroup()) ?
                   0 : Grid.CurrentPageIndex * Grid.PageSize;


                int maximumRows = (ShouldApplySortFilterOrGroup()) ?
   **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
                     MyBusinessObjectCollection1.SelectCount() : RadGrid1.PageSize;**

                Grid.AllowCustomPaging = !ShouldApplySortFilterOrGroup();

      **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
              RadGrid1.DataSource = MyBusinessObjectCollection1.Select(startRowIndex, maximumRows);**

As you can see i am not sure how to trnaslate that example code when using a data set. See the parts where I am noting "Here not sure how to translate...." Any help would be appreciated.

Regards

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

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

发布评论

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

评论(3

路弥 2025-01-01 12:19:05

我对这个问题有点困惑,所以我将包括我的例子,说明什么是有效的,也许这会对你的努力有所帮助。首先,我在网格上设置这些:

<!-- Set pageSize to whatever you want -->
<tel:RadGrid .. AllowPaging="true" AllowCustomPaging="true" PageSize="10" />

在代码中,当绑定时,我这样做:

//need to pass the total number of records there are; this is used to build
//the paging list
this.RadGrid1.VirtualItemCount = totalNumberOfRows;

//Bind the filtered resultset that has only 10 or whatever the page size amount of records are
this.RadGrid1.DataSource = x;
this.RadGrid1.DataBind();

本质上,您绑定过滤结果,但将虚拟项目计数设置为记录总数。 RadGrid 还应该支持绑定到 DataSet,因此这应该不是问题。

I'm a little confused to the problem, so I'm going to include my example of what DID work, and maybe that will help you in your endeavor. To start, I set these on the grid:

<!-- Set pageSize to whatever you want -->
<tel:RadGrid .. AllowPaging="true" AllowCustomPaging="true" PageSize="10" />

In code, when time to bind, i do this:

//need to pass the total number of records there are; this is used to build
//the paging list
this.RadGrid1.VirtualItemCount = totalNumberOfRows;

//Bind the filtered resultset that has only 10 or whatever the page size amount of records are
this.RadGrid1.DataSource = x;
this.RadGrid1.DataBind();

Essentially, you bind the filtered result, but set the virtual item count to the total number of records. The RadGrid should also support binding to a DataSet as well, so that shouldn't be a problem.

妞丶爷亲个 2025-01-01 12:19:05

这对我有用。

http ://www.telerik.com/community/forums/aspnet-ajax/grid/pager-arrows-problem-when-databinding-in-page-load.aspx

$('.rgPageFirst').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPageNext').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPagePrev').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPageLast').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgCollapse').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgExpand').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgExrgNumPart').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

this worked for me.

http://www.telerik.com/community/forums/aspnet-ajax/grid/pager-arrows-problem-when-databinding-in-page-load.aspx

$('.rgPageFirst').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPageNext').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPagePrev').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgPageLast').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgCollapse').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgExpand').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});

$('.rgExrgNumPart').live('click', function () {
    __doPostBack(this.name, '');
    return false;
});
甜柠檬 2025-01-01 12:19:05

我无法添加评论,但我可以发布答案。乔的想法是正确的。我只需将其更改为下面的代码并将其添加到我的 aspx 页面的脚本块中。

      $(function () {
        $('.rgPageFirst').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPageNext').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPagePrev').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPageLast').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });
      });

谢谢乔!

I can't add a comment, but I can post an answer. Joe had the right idea. I just had to change it to the below code and add it to the script block of my aspx page.

      $(function () {
        $('.rgPageFirst').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPageNext').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPagePrev').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });

        $('.rgPageLast').click('click', function () {
            __doPostBack(this.name, '');
            return false;
        });
      });

Thanks Joe!

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