TextColumn with SortType stDate
#1
Posted 20 November 2005 - 02:55 AM
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
Posted 20 November 2005 - 03:36 AM
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.
--
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
Posted 20 November 2005 - 12:37 PM
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
Posted 23 November 2005 - 12:55 AM
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
Posted 23 November 2005 - 01:19 AM
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
--
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
Posted 24 November 2005 - 01:49 AM
I will try it.
greetz,
Steffen
#7
Posted 20 December 2005 - 08:31 AM
#8
Posted 20 December 2005 - 12:53 PM
#9
Posted 20 December 2005 - 01:15 PM
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
--
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
Posted 31 December 2005 - 10:57 PM
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
Posted 01 January 2006 - 04:06 PM
Why not use a virtual column that reflects the content of a hidden date column in the format you want?
#12
Posted 02 January 2006 - 12:51 AM
Because if it is, then the problem still exists.
#13
Posted 02 January 2006 - 01:49 AM
Please read next article:
http://www.bergsoft....e=virtualcolumn
for Virtual Column, created by Wim.
--
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
Posted 02 January 2006 - 06:46 AM
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
Posted 02 January 2006 - 11:39 AM
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.
#16
Posted 10 January 2006 - 09:37 PM
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.
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
#18
Posted 24 January 2006 - 08:34 PM
please reply to this matter.
Also with the new Version it doesn't work and I really need a solution for this.
Please
greetz
Steffen
#19
Posted 25 January 2006 - 01:30 PM
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.
#20
Posted 25 January 2006 - 08:48 PM
but this also doesn't work
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
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users