亚音速寻呼顺序问题
我有一个数据网格,我在其中使用自定义分页选项(参考:http://subsonicproject. com/querying/webcast-using-paging/)在 Subsonic 框架中。
我还有一个按州过滤数据的下拉菜单。 这通过 addwhere 调用添加到查询中。
数据按州 ASC 排序,然后按城市 ASC 排序。
当未选择任何状态时,数据似乎排序良好,因此没有将 addwhere 添加到子句中。 但是,如果您选择的状态有足够的记录来启动分页,则某些记录会乱序显示。 我还注意到,当前页面上的最后几条记录似乎总是显示在网格中间的某个位置。
loadgrid 的代码片段:
Dim qry As New SubSonic.Query( {myTableSchema} )
If ddlStates.SelectedValue.Trim.ToLower <> "all states" Then
qry.AddWhere("state", ddlStates.SelectedValue.Trim)
End If
qry.ORDER_BY("state", "ASC").ORDER_BY("city", "ASC")
qry.PageSize = ddlDisplay.SelectedValue
qry.PageIndex = pageNumber
gvOrganizers.DataSource = qry.ExecuteDataSet
gvOrganizers.DataBind()
当选择一个状态并且只有 1 页数据时,问题似乎不会出现。 默认 ddlDisplay 设置为每页 100 条记录,但即使选择 50 或 25 条也会出现错误。
使用亚音速 2.1.0.0
I have a datagrid where I am using the custom paging option (ref: http://subsonicproject.com/querying/webcast-using-paging/) in the Subsonic framework.
I also have a dropdown that filters the data by State. This is added to the query through the addwhere call.
the data is ordered by state ASC and then city ASC.
the data seems to be ordered fine when no state is selected and thus no addwhere is added to the clause. But if you select a state that has enough records to cause pagination to kick in, then some records are displayed out of order. I have also noticed that it always seems to be the last few records on the current page are displayed somewhere in the middle of the grid.
snippet of code to loadgrid:
Dim qry As New SubSonic.Query( {myTableSchema} )
If ddlStates.SelectedValue.Trim.ToLower <> "all states" Then
qry.AddWhere("state", ddlStates.SelectedValue.Trim)
End If
qry.ORDER_BY("state", "ASC").ORDER_BY("city", "ASC")
qry.PageSize = ddlDisplay.SelectedValue
qry.PageIndex = pageNumber
gvOrganizers.DataSource = qry.ExecuteDataSet
gvOrganizers.DataBind()
The problem doesn't seem to appear when a state is selected and there is only 1 page of data. Default ddlDisplay setting is 100 records per page but the error appears even if 50 or 25 is chosen.
Using Subsonic 2.1.0.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 qry.OrderAsc(New String(){"state asc, city asc"})
Use qry.OrderAsc(New String(){"state asc, city asc"})
PAGING_VIEW_SQL
模板中似乎存在错误(SqlProvider.cs
,第 1702 行)。 以下是代码片段:您可以看到,首先排序的数据被排序并插入到临时表中,但随后检索所需的页面而无需再次排序。 最终导致为请求的页面获取正确的数据,但没有正确的排序。
需要修改第二个
select
,以便从临时表中获取数据时顺序正确。 像这样:当然,然后重新编译代码就可以了:-)
There seems to be a bug in
PAGING_VIEW_SQL
template (SqlProvider.cs
, line 1702). Here is the snippet:You can see that at first ordered data is sorted and inserted into a temp table but than the required page is retrieved without sorting again. Which in the end results in getting the right data for the requested page but without proper sorting.
The second
select
needs to be modified so that the data is in the correct order when it is taken from the temp table. Like this:and then of course recompile the code and off you go :-)