Sorting a DBView by clicking the header - D2009

Howdy!

I tried compiling a bit of code under Delphi 2009, but hit a brick wall,
when my old piece of code for sorting the DB (Access in case you wonder
why I ask it here) based on the trick I see in all places.

The little nice snippet pasted here won't work:

http://delphi.about.com/od/usedbvcl/l/aa042203a.htm

The "pos" part of things now generates an error. Any suggestions on how
to quick fix it?

/Pontus
0
Pontus
9/25/2008 10:50:42 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

1 Replies
485 Views

Similar Articles

[PageSpeed] 58

Pontus Berg skrev:
> Howdy!
> 
> I tried compiling a bit of code under Delphi 2009, but hit a brick wall,
> when my old piece of code for sorting the DB (Access in case you wonder
> why I ask it here) based on the trick I see in all places.
> 
> The little nice snippet pasted here won't work:
> 
> http://delphi.about.com/od/usedbvcl/l/aa042203a.htm
> 
> The "pos" part of things now generates an error. Any suggestions on how
> to quick fix it?
> 
> /Pontus


Answering my own question, doihng a bit of typecasting did the trick. 
I'm not saying this is by the book, nice but it worked - please see the 
RawByteString() insertions;

   with TCustomADODataSet(SelectGrid.DataSource.DataSet) do
   begin
     if (Pos(RawByteString(Column.Field.FieldName), Sort) = 1) and 
(Pos(RawByteString(' DESC'), Sort)= 0) then // <- Error here!
       Sort := Column.Field.FieldName + ' DESC'
     else
       Sort := Column.Field.FieldName + ' ASC';

     If Column.Field.FieldName = 'MCC' then
        ADO_Progress.Sort := 'MCC ASC, MNC ASC'
     else
        ADO_Progress.IndexFieldNames := sort; /// TEST!
   end;

/Pontus
0
Pontus
9/25/2008 11:25:33 PM
Reply:

Similar Artilces:

sort by clicking on the datagrid header
How can I do so? How can I detect when the user clicks on the header? Thanks in advance. You need to specify the SortExpression property of each column, set this property in the grid declaration header: AllowSorting="true" and implement Sort event handler of the grid.Bug [MCSD] Ok, I have get the sort working, but I got another problem. I have paging implemented in my datagrid. When I move to page 2 of my datagrid and I click on any of the header to sort, it will sort the entire datagrid. This is not what I want. What I want is, when the user is at page 2 and click ...

Sorting by clicking in the column-header ???
PB 10.5 Is there any possibility to sort by a column, if I click only on the header-text of the column ? ( like in EXCEL ) Thanks Peter Peter Stojkovic wrote: > PB 10.5 > > Is there any possibility to sort by a column, if I click only on the > header-text of the column ? > ( like in EXCEL ) yep very easily the trick is to name your text headers something like ( <columnname>_t or t_<columnname> ) then in the clicked event of the DW ( assuming <columnname>_t ) String ls_col If row = 0 Then ls_col = Left( dwo.name, len...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Sorting a grid datawindow by clicking on header
Hi all I have made a sorting routine that sorts a datawindow when the user clicks on one of the columns in the header band. The problem is when the datawindow is of the "grid" type. When I click on a header column the sort works ok, but all the rows in the column get selected at the same time. The background color of all the rows in the column becomes black. I think this has to do with the "moveable" property for the columns. But I need to keep the "moveable" property enabled because the users need to be able to reorder the columns. Can I prevent...

sort by dw header column when clicked?
I'm sure this has been asked a zillion times before: is there a way to create a header column in a datawindow that will sort by that column when clicked? I seem to remember there's a way to do it in the PFC but not otherwise. You will have to manually code this. First you will have to name your column labels similar to the column it represents (e.g. column name + _t). In the clicked event of the datawindow you would do something like this: IF Right(dwo.Name, 2) = '_t' THEN IF Describe('Datawindow.Table.Sort') = Left(dwo.Name, Len(dwo.Name) - 2) +...

Sorting by clicking in the header-Text of column ?
DW. DOT.NET 2.0 Is there any possibility to sort by a column, if I click only on the header-text of the column ? ( like in EXCEL ) Thanks Peter Make sure the column headers have the same name as the underlying column, except with a _t suffix: Subclass the control and add this on an override of the OnClicked event, or add this to the OnClicked event of the control when you put it on a form: clickedobject = MyBase.ObjectUnderMouse() If clickedobject.Band.Type = Sybase.DataWindow.BandType.Header Then objectname = clickedobject.Gob.Name...

How to sort a gridview column when a header is clicked
Hello All,   I have a gridview where I am displaying Filename, Date uploaded , size etc. Now I want to sort the gridview in ASC and DESC order on click of the column header. If the user clicks a column header say "Date Uploaded" data should be sorted according to that column... Can anyone tell me how can I do this... Warm Regards     hey bugposter,Try this,             Sorting a Gridview  try sample:aspx.cs: protected void Page_Load(object sender, EventArgs e)  &nbs...

Sorting mail by clicking on header block
Recently, I found an option in the Config Editor to prevent sorting mail by clicking on a header block. I now find that the convenience of sorting by header block far out-weighs the occasional click-accident that invariably happens. My problem is that I've forgotten which option I changed in order to turn header block sorting back on. Could someone please point me to the appropriate key in about-config? Many thanks for your help. Alain On 02.02.2009 20:26, CET - what odd quirk of fate caused Alain Rochon to generate the following:? : > Recently, I found an optio...

Datagrid is gone when I click the sorting column header
Hi experts, I have drowdownlists to filter the data in datagrid, a "View" and a "Edit" hyperlink columns in my datagrid. They all work fine when I select or click them. However, only if click the underlined column header for sorting, my datagrid is gone! I set AllowSorting="True" OnSortCommand="SortCommand_OnClick" in my datagrid and my sort funcation is like : Sub SortCommand_OnClick(ByVal Source As Object, ByVal E As DataGridSortCommandEventArgs) SQLStmt = SQLStmt & " ORDER BY " & E.SortExpression ...

Gridview sorting when header text with image click
 Hi,      I am using grid view for display client details.I am doing Sorting process as First Name Column.     I am mention First Name column in the Template Field Header Text.When click the First name in the Grid the corresponding values is  displayed as a sorting.When click the Ascending , the Ascending image is added in the header.when i click the Descending , descending image is added in the First Name header. But I need the Header name with Ascending image in the Template Field Header Text.  I need to click both Image and FirstName in th...

sort by click on grid view column headers
sorting custom grid view control. when the user clicks onthe column header that needs to be sorted. Please post answer asap So you have an asp:GridView control bound to a datasource is my assumption here? In the gridview, set AllowSorting= True and in the BoundColumns, set the SortExpression="FieldNameFromDataSourceToSortBy". Does that help? For examples head onover to to the Quickstarts for the datagrid.  http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/gridview.aspx Cheers, StevePlease remember to 'Mark as Answer' if this post answered your que...

How to code, When clicked DataWindow Column Header then sort ?
Hello to you, How to code, When clicked DataWindow Column Header then sort ? Pls advice steven try copy it from PFC function "steven" <stvhui@yahoo.com> wrote in message news:fNYZJGCECHA.70@forums.sybase.com... > Hello to you, > > How to code, When clicked DataWindow Column Header then sort ? > > Pls advice > steven > > > ...

Click...click...click
I was listening today to a photography podcast at: www.photography.ca/blog and the host Marko described the loss of the hard drive which contained a backup of all his images. He said that one morning he tried to boot up, and the drive just went "click... click... click" but never did anything more, and of course wouldn't boot. Is there a reasonable chance that Spinrite could fix that, or does that behavior indicate a physical problem with the drive head or electronics? Peabody wrote: > I was listening today to a photography podcast at: > > www...

click click click
the subject line is a sound that eminates from the harddrive of a laptop (not mine) with xp pro/ntfs unit powers up, unable to access the c drive. same results with a bootable floppy disk. I assume there is nothing else that can be done unless one wants to pay a company to recover the data? "mgwmp" <p.zie@cnn.com> wrote in message news:blv77g$i9q$1@news.grc.com... > the subject line is a sound that eminates from the harddrive of a laptop > (not mine) with xp pro/ntfs > > unit powers up, unable to access the c drive. same results with a bootable >...

Header sort service and clicked code not working together.
I have a pfc tabular dw using the sort on header service and performing additional processing in the descendent clicked event of the datawindow. The clicked event of the datawindow basically retrieves another dw with additional information (one to many). When the user clicks on the column headers (to sort) I did not want the descendent code to process , so I check the dwo.band and if the band is not "detail" I return out of the event. // Dont process if the clicked row if not in the detail band CHOOSE CASE dwo.Band CASE "detail" � //Continue CASE ELSE � return ...

Web resources about - Sorting a DBView by clicking the header - D2009 - embarcadero.delphi.ado

WARNING: Unhappy Meals for Facebook Users Clicking Links to $250 McDonald’s Gift Cards
Facebook users who click on links promising them $250 gift cards to McDonald’s are becoming victims of The Hamburglar, in the form of online ...

Facebook tests subscribe button for pages to allow users to receive updates without clicking Like
... Marketing Land reader Craig Smith: We do not have the button on our own accounts, but here is the way to connect with a page without clicking ...

Macintosh User Manual - Clicking - Flickr - Photo Sharing!
Explore peterme's photos on Flickr. peterme has uploaded 5226 photos to Flickr.

Shoes of Prey not the only e-tailer clicking onto bricks and mortar
Aussie internet merchants are realising that an old-school shop front is still vital for building brand and sales.

Shutting down and clicking on (04:36)
While the American government shut down explored absurdity, we have had to make do with mere bemusement over Harvey Norman chief Gerry Harvey’s ...

Want a top Australian Public Service job? Get clicking on Facebook
Click 'Like' if you have what it takes to be a Canberra mandarin.

Shoes of Prey not the only e-tailer clicking onto bricks and mortar
Aussie internet merchants are realising that an old-school shop front is still vital for building brand and sales.

Shutting down and clicking on (04:36)
While the American government shut down explored absurdity, we have had to make do with mere bemusement over Harvey Norman chief Gerry Harvey’s ...

Shoes of Prey not the only e-tailer clicking onto bricks and mortar
Aussie internet merchants are realising that an old-school shop front is still vital for building brand and sales.

Shutting down and clicking on (04:36)
While the American government shut down explored absurdity, we have had to make do with mere bemusement over Harvey Norman chief Gerry Harvey’s ...

Resources last updated: 12/21/2015 6:49:00 AM