Jump to content


Photo

TextColumn with SortType stDate


  • Please log in to reply
19 replies to this topic

#1 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 20 November 2005 - 02:55 AM

Hello Boki,

I have a problem with SortType=stDate.
I have a TextualColumn and in some rows is a Date and in some there is none (it's empty).
Now, when I want to sort that column I get an error that '' is not a valid date.

Obviously, the empty rows are the problem, if I have all rows filled with date strings, everything is fine.

greetz
Steffen

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,194 posts
  • Gender:Male

Posted 20 November 2005 - 03:36 AM

Hello Steffen,

Do you have try to use DataColumn instead, and then use HideWhenEmpty property when Date is equal to 0?

I think that this will be good solution for you.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 20 November 2005 - 12:37 PM

Hello Boki,

this works, but now, everytime I click into a empty cell (edit mode), the first date shows up (30.12.1899). This should also be empty.

Still, I think it's a bug with the textual column, there shouldn't be an error when the cell is empty.

thanks and greetz,
Steffen

#4 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 23 November 2005 - 12:55 AM

Hello Boki,

I really need a solution for this.

The Textual Column raises exceptions when I sort with stDate and a Cell is Empty and the DateColumn is never really empty, I always get a 30.12.1899 out of it.

Thanks in advance,
Steffen

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,194 posts
  • Gender:Male

Posted 23 November 2005 - 01:19 AM

Hello Steffen,

I think that you realy need to use DateColumn, but in OnBeforeEdit set NextGrid1.InplaceEdit.Text := 'some value' when you detect that Cell contain empty date.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 24 November 2005 - 01:49 AM

Thanks,

I will try it.

greetz,
Steffen

#7 jz

jz
  • Members
  • 13 posts

Posted 20 December 2005 - 08:31 AM

BTW, is it possible to set the format for a NxDateColumn? It looks like it doesn't have a property for that.

#8 daniel_r

daniel_r
  • Members
  • 29 posts

Posted 20 December 2005 - 12:53 PM

I already asked for that a few months ago.

#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,194 posts
  • Gender:Male

Posted 20 December 2005 - 01:15 PM

Hello,

Format is used from global Date format variable in whole application.

I don't know is it good idea to have separate property for every DatePicker

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#10 jz

jz
  • Members
  • 13 posts

Posted 31 December 2005 - 10:57 PM

I agree that for a data entry grid it wouldn't be a good idea since people will expect to enter it the same way in each program. However, sometimes I use the grid in a pure read only fashion say for displaying a summary.

E.g. if i am grouping data by month then something like "yyyy/mmm" makes more sense since I don't need to display the individual day of the month. Now I could use string field to diplay that, but it will not sort properly.

In fact, the automatic ability to sort using the stored value with the option to display another would be useful in the other column types too. So maybe rather than adding a format property for the date column type, you should add a GetDisplayStr() event to TNxCustomColumn class.

#11 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 01 January 2006 - 04:06 PM

Hi,

Why not use a virtual column that reflects the content of a hidden date column in the format you want?
G.W. van der Vegt

#12 jz

jz
  • Members
  • 13 posts

Posted 02 January 2006 - 12:51 AM

There is no documentation or demos for the virtual column type, but it appears to provide only a single event (OnGetText) which would be used for both sorting and displaying. Is that correct?

Because if it is, then the problem still exists.

#13 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,194 posts
  • Gender:Male

Posted 02 January 2006 - 01:49 AM

Hello,

Please read next article:
http://www.bergsoft....e=virtualcolumn

for Virtual Column, created by Wim.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#14 jz

jz
  • Members
  • 13 posts

Posted 02 January 2006 - 06:46 AM

That article doesn't contradict what I said - even with a virtual column you have to use the same value to both sort and display.

But what do I do if I want to sort one way and display differently?

Now I could store the data using using the display format, and then use a custom compare function to convert it back and then compare it, but for some formatting the compare would become very convoluted. It would be a lot cleaner if there was an event to get the caption to display instead.

#15 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 02 January 2006 - 11:39 AM

Hi,

You could sort on a hidden column that contains data that sorts correctly for your purposes (like the data as the number of seconds) and display it in another (virtual) column.

But for the date stuff i could imagine that Boki could implement a format property that calls the dateformat routines whenever the property is present. That way you don't specify the date-time format of the column but it's display format.

And I agree we need an OnCompare event for custom sorting. But I'm not sure if it should be on a column level or on grid level. It would need the ability to display multiple sortmarkers and the ability to delete them (so 3 clicks to cycle through up/down/none). Drawback is that it's not the standard way in windows land.
G.W. van der Vegt

#16 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 10 January 2006 - 09:37 PM

QUOTE (Boki)
Hello Steffen,

I think that you realy need to use DateColumn, but in OnBeforeEdit set NextGrid1.InplaceEdit.Text := 'some value' when you detect that Cell contain empty date.

regards


Hello Boki,

some time has passed and now I've tried what you said.
But I think I make something wrong.
I always get Access Violations and the InplaceEdit.Text property doesn't exist. There's only a EditText property, so I've tried this.

CODE
if ACol=colDate then

begin

 //if NextGrid1.Cell[ACol,ARow].AsString='' then  <-- with or without it, it doesn't work

   NextGrid1.InplaceEdit.EditText:='10.11.2005';  // Test input

 //end;

end;


greetz
Steffen

#17 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 12 January 2006 - 02:50 PM

no idea? sad.gif

#18 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 24 January 2006 - 08:34 PM

Hello Boki,

please reply to this matter.
Also with the new Version it doesn't work and I really need a solution for this.
Please smile.gif

greetz
Steffen

#19 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 25 January 2006 - 01:30 PM

Hi masterevil,

I think the correct way is to use:

Columns[ACol].Editor.Text :='10.11.2005';

as the Columns[ACol].Editor is assigned to the Grids InPlaceEdit after OnBeforeEdit is called.
G.W. van der Vegt

#20 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 25 January 2006 - 08:48 PM

Thanks,
but this also doesn't work sad.gif

It doesn't create an access violation, but the value doesn't change at all.
I also tried to set Editor.AsString or Editor.AsDateTime, but this also doens't work.

It's frustrading.

greetz
Steffen




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users