Jump to content
Software FX Community

Sorting


vaioklm

Recommended Posts

Posted

I've got a datetime field that can sometimes contain a NULL.  When NULL, the user wants to see "00/00/0000 00:00"; but they want NULL to be treated as "12/31/9999" when sorting.  Is it possible to create a column that displays one item in my dataset, but sorts based on a different item?

Posted

In the example I gave, yes; but there are many other scenarios where this wouldn't be the case.  Our applications often show text descriptions for alphanumeric codes, but when the user sorts the description, they actually want the sort based on the code rather than the description they are looking at.  What I'm really looking for is functionality similar to the .NET datagrid if you create a BoundColumn and set the BoundColumn.DataField = "col_a" and the BoundColumn.SortExpression = "col_b".

Posted

Well, it's very easy to format the values shown to the user for a particular field while the grid uses the underlying data values to sort.  Handling the FormattingDataValue event will take care of that.  In that case, you could format null values as you wish, while the grid will sort nulls as if they are equal to DateTime.MinValue.

Regarding the SortExpression on individual fields, that capability could be built into the product, but those things take time.  It will get done, but the way to accomplish your desired result is to check out the formatting events like FormattingDataValue.  They are very cool.  If you need a code sample, just let me know.  Thanks so much for using Grid FX!

  • 4 months later...
Posted

Hi, We are using the GridFX for some time now. For one of screen on the application, we are facing sorting issue for Date column.

When the data is displayed in the column, data is formatted (from Database) in Text format & displayed in Grid. The Column Type for that column is DateTimeField. Currently when user tries to sort the Date Column, data is treated as Text & is sorted accordingly, instead of Date Sorting. User would like to see the data in Grid to be sorted according to the Date datatype. Please share the code samples..

Posted

I'm a little unclear.  In the database the column is text, but in Grid FX it's a FieldColumn that points to a DateTimeField?  Could you send me the grid markup?  That would help a lot. 

Posted

The Data type for the column in Database is DateTime. While retrieving the data for populating the grid, we are coverting the DateTime to VarChar so as to truncate any time component. Also if the date column is null we are replacing that by blank value.

The corresponding column in GridFX is of type DateTime, since the sorting will be done on Date & not on the Text type.

We are able to display the Date value, formatted as Text, in the DateTimeField column of the Grid. But when we try to sort on this Date column, it treats the column type as Text as sorts as per the Text values in the column.

User would like to see the data in Grid to be sorted according to the Date values & not as per Text values in the column. Please share the code samples.

Thanks

 

Posted

Please ignore earlier message.

Actually there are two columns in Grid: Data Type for one is DateTime & other is TextField. The First column is going to hold the value from Database which will be of Date type & second column will hold formatted value (Text Value). The Data Type for both the columns in database is DateTime. Since the second column can contain Null value, we need to convert that to blank, which will be Text data.

The Date column is sorted correctly, but when user try to sort on the other column, it treats the column type as Text and sorts as per the Text values in the column. How we can handle this situation? Please share the code samples.

Apart from this, User would like to see the Date column to be sorted in Descending order by defaut, when screen loads. I belive currently when Sorting is enabled, the data is sorted in Ascending order on the specified column. How to force descending sorting on page load.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...