Article View: borland.public.delphi.aspdotnet.components.using
Article #161Re: Sorting in DBWebGrid
From: John Moshakis
Date: Thu, 02 Feb 2006 03:02
Date: Thu, 02 Feb 2006 03:02
43 lines
2081 bytes
2081 bytes
John Mace wrote:
> Hi,
>
> Using D2006E, I'm having a problem sorting a DBWebGrid. When I set
> AllowSorting to True, the header is underlined and makes a round trip
> to the server when clicked as expected. Althought the Sort Expression
> is properly set through the Property Builder, the grid is not sorted.
>
> It seems to me that there is sufficient information in the property
> settings to perform the sort. What am I missing?
>
> John
Hi John,
You need to add a SortCommand event handler and perform the sorting
yourself.
A couple of things to be aware of with the dbwebgrid. When you postback
it applies any changes you have made on the client into the dataset.
You therefore have to make sure that the selected row is the same
before and after you have applied the sort. Something like
SortCommand(source:TObject;e:DataGridSortCommandEventArgs)
begin
selectedIndex:=dbWebGrid1.SelectedIndex
{get the primary key value for that row
{perform the sort}
{find the index of the row with the primary key value}
(dbWebDataSource1 as Borland.Data.Web.IDBPostStateManager).SetCurrentRow
end
The other thing you need to be aware of that the dbwebdatasource is
caching the dataset and I think this interferes with the sorting so set
AutoRefresh to true and do the caching yourself.
Cheers,
John
--
Technical Details
Message-ID:
<43e18447@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<43e0a63b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 21665a,389ecb60fa9cc66d X-Google-Attributes: gid21665a,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John Moshakis" <john@moshakis.com> Subject: Re: Sorting in DBWebGrid Newsgroups: borland.public.delphi.aspdotnet.components.using References: <43e0a63b$1@newsgroups.borland.com> User-Agent: XanaNews/1.17.6.6 NNTP-Posting-Host: 70.25.0.115 Message-ID: <43e18447@newsgroups.borland.com> Date: 1 Feb 2006 20:02:15 -0700 X-Trace: newsgroups.borland.com 1138852935 70.25.0.115 (1 Feb 2006 20:02:15 -0700) Lines: 44 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail