﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Fri, 11 Jan 2013 05:24:55 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>Hi Eric,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;To resolve this matter, maybe we have workaround for you. You can add SortKeyField property on column that you want to sort. In last sample, I put SortKeyField="Unique_ID" so the custom column will be sorted regarding its Unique_ID. Actually our WebGrid sort the value regarding its data so it will more flexible to control the interaction with database. Hope this helps.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Regards,&lt;/div&gt;
&lt;div&gt;Bernard&lt;/div&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Tue, 04 Sep 2012 00:21:47 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;Hi Eric,&lt;/p&gt;&lt;p&gt;This problematic behaviour has already added as feature request #1255. I'll let you know if I heard any news regarding this issue.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bernard&lt;/p&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Thu, 30 Aug 2012 04:36:29 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;Hi Bernard&lt;/p&gt;
&lt;p&gt;Thanks. As a final comment, if there will be maybe a feature to sort by displayed text, this means that the sorting must be done after the InitializeRow events, because the texts get changed in InitializeRow. So it would be good if the sorting-relevant data could be changed in that event too. Consider a list of calculated date values, that should be sorted by time and not alphabetically. So only the option to switch to text-sorting might not be sufficient for that case. So the best way to add such a feature would be to allow changing the underlying data value (or a special sorting-relevant data value) in InitializeRow event.&lt;/p&gt;
&lt;p&gt;For our project this is now not very important anymore, as we have to implement the workaround anyway. But having such a feature would still be good. Please ping to this thread in case there's any update.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Wed, 29 Aug 2012 22:19:53 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;Hi Eric,&lt;/p&gt;&lt;p&gt;I think the best way to do your scenario is by using DataTable that you mentioned above. In InitializeRow event we can set the value of the cells (it's not read only I think) but it seems the row has been sorted in InitializeRow. It's more elegant if we have feature for sorting by text instead of value. I'll make this feature request and I'll contact you if I heard any feedback from our developer. Thank you for your feedback.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bernard&lt;/p&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Wed, 29 Aug 2012 04:29:23 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;Hi Bernard,&lt;/p&gt;
&lt;p&gt;I looked at your changes and can see that you just changed the data given to the WebGrid in InitializeRow. That's kind of cheating. Normally, there would be a database call instead of this hardcoded stuff. Of course we could add this logic into the database, but these text modifications are just for displaying, so I don't think this belongs logically into the database and I don't want to do that.&lt;/p&gt;
&lt;p&gt;I also tried to change ListName.Value in the InitializeRow event handler in the same way as ListName.Text, but it had no effect. Probably that value is read-only there or something.&lt;/p&gt;
&lt;p&gt;So from what I see now, the only way to solve this would be that after the database call in InitializeDataSource I copy the returned resultset into a DataTable and add a column, loop through all rows and set the display value there instead of in InitializeRow event handler. Then I could remove the code in InitializeRow. That way the underlying .Value has the correct values for sorting. I could also set the SortColumn property, but I would still need to create the data column. I don't like to loop through DataSets, but this seems to be the only solution for now.&lt;/p&gt;
&lt;p&gt;Yes, having a property to sort by the displayed text instead of the underlying value would be a good idea. Please suggest such a feature request. An even better way (or additional feature) would be some way to modify the underlying data value (and/or the sort value) within the InitializeRow event handler.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Tue, 28 Aug 2012 23:46:15 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>Hi Eric,&lt;div&gt;&lt;br /&gt;&lt;div&gt;Unfortunately, for now, our WebGrid take cell's value as sorting parameter. This problem occurs because the value of List_Name cell is different with its text (example: List_Name.Value = "a" and List_Name.Text = "-Fil-a-"). You can do this by set its value to same string like in the text.&lt;/div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;I have edit your sample and attach it here. Could you check the attached sample here and tell me if there's misconfiguration and mistake that I made? And if you have any scenario that insist you to use Text as sorting parameter, I'll make this scenario as feature request. Hope this helps.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Regards,&lt;/div&gt;
&lt;div&gt;Bernard&lt;/div&gt;</description></item><item><title>How to sort WebGrid by displayed text instead of underlying data?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-How-sort-by-displayed-text/</link><pubDate>Tue, 28 Aug 2012 06:28:28 GMT</pubDate><dc:creator>Eric</dc:creator><category>WebGrid</category><category>InitializeDataSource</category><category>Event</category><category>sort</category><category>InitializeRow</category><category>e.Row.Cells.GetNamedItem().Text</category><category>CustomSort</category><description>&lt;p&gt;See this thread for code example:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.intersoftpt.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/"&gt;http://www.intersoftpt.com/Community/WebGrid/WebGrid-How-to-access-Session-object-in-InitializeRow-event-handler/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There's a sorting problem. When sorting by this Name field, it will get sorted by the value in the DataTable from InitializeDataSource, field List_Name. But in InitializeRow I set the ListName.Text (e.Row.Cells.GetNamedItem("xx").Text) to the value that will be displayed. In the case of this example I prepend just "-DIR-" for folders and "-FIL-" for leaf-nodes. When sorting, it won't get sorted by the displayed text, but by the underlying data field (before updating). For this example, the root-level entry "-FIL-a-" comes before "-DIR-b-", just because "a" comes before "b", but the final text is ignored ("-D.." would come before "-F..").&lt;/p&gt;
&lt;p&gt;How can I make sure the list gets sorted by the displayed text? Would I have to implement CustomSort event? How?&lt;/p&gt;</description></item></channel></rss>