Jump to content
Software FX Community

Sorting


vaioklm

Recommended Posts

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?

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 4 months later...

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..

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...