Dynamic filter order byhttp://forums.asp.net/t/1196276.aspx/1?Dynamic+filter+order+byThu, 04 Dec 2008 22:25:08 -050011962762068601http://forums.asp.net/p/1196276/2068601.aspx/1?Dynamic+filter+order+byDynamic filter order by <p>I've customized one of my pages not to use the templates.&nbsp; I've removed the FilterRepeater and just have one Dynamic Filter on the page.&nbsp; My question is, is there a way to order the contents of the drop down list that the Dynamic Filter creates?&nbsp; Do I need to create a partial class for that table and do something on the OnLoaded event?&nbsp; Thanks in advance.&nbsp;</p> 2007-12-19T16:19:48-05:002068864http://forums.asp.net/p/1196276/2068864.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>&nbsp;That's a great question.&nbsp; I was just about to post that one myself . . .<br> </p> 2007-12-19T18:43:01-05:002069421http://forums.asp.net/p/1196276/2069421.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>There currently is no way to customize this. For future releases, we are thinking of having an extra metadata attribute that would let you declare the column to sort on (plus asc/desc). Is there any extra functionality you would like to see in this area?</p> <p>Thanks</p> 2007-12-20T01:05:54-05:002070560http://forums.asp.net/p/1196276/2070560.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Well, I started customizing the dynamic filter because I needed a human readable label next to the drop down list, not just the table name.&nbsp; It would be nice to have an attribute for every column and table name so that you could provide your own custom string that would be displayed in the grid column headers and the filter labels etc.<br> </p> 2007-12-20T13:55:23-05:002070589http://forums.asp.net/p/1196276/2070589.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Although it may not be practical for your solution, one workaround would be to&nbsp;rename the tables in the LinqToSql class.&nbsp; You can click do it directly in the designer.</p> 2007-12-20T14:03:05-05:002070611http://forums.asp.net/p/1196276/2070611.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by Strange, I swear I tried that before and it didn't work, but now it is.&nbsp; Thanks.<br> 2007-12-20T14:13:59-05:002070631http://forums.asp.net/p/1196276/2070631.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>For some reason, after you rename the tables in your LINQ to SQL diagram, you have to close the diagram and reload it in order for the new names to take effect.&nbsp; The names change in the diagram in real time, however they are not seen programmatically untill you reload the diagram.&nbsp; The same thing happened to me.&nbsp; I'm afraid it may be similar to the cashing issue in another topic on this forum which we are currently waiting on a work around for.</p> 2007-12-20T14:24:43-05:002071196http://forums.asp.net/p/1196276/2071196.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Thanks for the input everyone,</p> <p>We already have plans to add extra metadata attributes to let you provide friendlier names for columns and filters, as well as better customization for sorting. They will come in particularily handy if you have an externally created data model that you can't edit yourself.</p> 2007-12-20T19:16:03-05:002377012http://forums.asp.net/p/1196276/2377012.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>So I was wondering if this issue has been resolved yet.</p> <p>I am trying to sort a automatically generated dropdown in an DynamicGridView, and would love to know if there is a metadata attribute I can use to do that.</p> <p>Right now it is sorting by the column's ID field rather than its Name field.&nbsp;</p> <p>thanks,</p> <p>case<br> &nbsp;</p> 2008-05-23T14:54:17-04:002377043http://forums.asp.net/p/1196276/2377043.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Marcin in the third post in this thread just said there is no way to do this currently (and I suspect in the verion that will RTM) to do the sort. However Marcing is also doing some samples see <a class="" href="http://blogs.msdn.com/marcinon/archive/2008/05/22/dynamic-data-samples.aspx"> here</a> one sample is <strong>Extending the FilterRepeater</strong> which may give us insite as to how we could do it our selves.</p> 2008-05-23T15:05:10-04:002377108http://forums.asp.net/p/1196276/2377108.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>&nbsp;Hi Case,</p> <p>first of all because you are referring to DynamicGridView it's probably the case that you are using the December '07 CTP. That version is quite outdated at this point and I would invite you to download either the <a href="http://asp.net/downloads/3.5-extensions/">.NET Framework 3.5 SP1</a> or the cutting edge version of <a href="http://code.msdn.microsoft.com/dynamicdata">Dynamic Data on Code Gallery</a>.</p> <p>Once you have the recent bits, you can use <a href="http://vs2008sp1docs.msdn.microsoft.com/en-us/system.componentmodel.dataannotations.displaycolumnattribute.sortcolumn.aspx"> DisplayColumnAttribute.SortColumn</a> to provide sorting information.</p> 2008-05-23T15:27:56-04:002769286http://forums.asp.net/p/1196276/2769286.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>I know that this is an older posting.&nbsp; Has this been added yet?&nbsp; I really desparately need this functionality.</p> <p>I have seen posts about work arounds, but am too much of a noobie to have a clue what they are talking about.&nbsp; I am just now learning VB, so people throwing code at me and saying &quot;add it&quot; doesn't help me much.&nbsp; I really need to know more specifics, like WHERE to add it.</p> <p>If anyone has any suggestions or help they can provide, I sure would appreciate it.</p> <p>&nbsp;I have tried this &quot;<a href="http://vs2008sp1docs.msdn.microsoft.com/en-us/system.componentmodel.dataannotations.displaycolumnattribute.sortcolumn.aspx">DisplayColumnAttribute.SortColumn</a>&quot; and the link doesn't work...so tried searching for it, but doesn't seem to be for the Filters...at least not from what I am understanding.<br> </p> <p>&nbsp;Thanks, Ann <br> </p> 2008-11-26T12:15:09-05:002769355http://forums.asp.net/p/1196276/2769355.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Have a look at this I think it may be what you need:</p> <p><pre class="prettyprint">[MetadataType(typeof(EmployeeMD))] [DisplayColumn(&quot;LastName&quot;,&quot;LastName&quot;,false)] public partial class Employee { public class EmployeeMD { public object EmployeeID { get; set; } [UIHint(&quot;MultilineText&quot;)] public object LastName { get; set; } public object Title { get; set; } public object TitleOfCourtesy { get; set; }<br> //... more fields here } }</pre> </p> <p>the DisplayColumn takes 3 parameters </p> <ol> <li>Is the column to display </li><li>Is the <strong>column</strong> to sort on </li><li>Is set to true for dort descending </li></ol> <p>This affects the Filters and the ForeignKey_Edit filedTemplates.</p> <p>Hope this helps [:D]</p> 2008-11-26T12:56:27-05:002769385http://forums.asp.net/p/1196276/2769385.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Again...WHERE does it go?&nbsp; I have no idea which file this would need to go in.&nbsp; I already have this information, but have tried to figure out where to put it and cannot determine it.</p> <p>Do you put it into the ForeignKey_Edit Template?&nbsp; Do you put it in the Custom Template for the Table you want to use it on?&nbsp; Do you put it in the Default page?&nbsp; What about the pages that handle ALL of the Tables...does it go in that file?</p> <p>Also, is 'EmployeeMD' the table name or is 'Employee' the table name?&nbsp; Whichever is not the table name...what is it?&nbsp; A column in the table?&nbsp; Or a new name?</p> <p>I kind of get the feeling that the 'EmployeeMD' is the table and that the 'public objects' are the columns...&nbsp; Is that right? <br> </p> <p>&nbsp; Thanks, Ann <br> </p> 2008-11-26T13:10:54-05:002769416http://forums.asp.net/p/1196276/2769416.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>You create a partial class file (in the App_Code folder in a file based website) along with the Linq to SQL files. You create a class with the partial class that represent the entity in the Linq to SQL classes (Look in the &lt;ModelName&gt;.designer.cs file for the class names etc) and then add the metadata, also see these videos here: <a href="http://www.asp.net/learn/3.5-SP1/"> http://www.asp.net/learn/3.5-SP1/</a>&nbsp;in the ASP.NET Dynamic Data section.</p> <p>Hope this helps [:D]</p> <p>&nbsp;</p> <p>&nbsp;</p> 2008-11-26T13:20:53-05:002769543http://forums.asp.net/p/1196276/2769543.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Okay, I have done what I think you said to do, but am getting errors.</p> <p>I created a new class file in the App_Code folder called &quot;Series_Master_Best_Cost&quot;, which is the name of my table, and it is how the class is declared in the 'designer.vb' file in the App_Code folder.</p> <p>I changed the parameters in 'DisplayColumn' to &quot;User_Master&quot;, which is the column name for the Filter that I need sorted in alphabetical order. <br> </p> <p>It is complaining about 'DisplayColumn', saying &quot;Declaration Expected&quot;.&nbsp; I made a declaration, but still didn't seem to like it.</p> <p>I had to comment out 'Option Strict On' because it kept complaining about the parameters for 'DisplayColumn', but that still did not fix things.</p> <p>Here is the error information I am getting:</p> <p><span></p> <h2><i>Input string was not in a correct format.</i> </h2> </span><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b>Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br> <br> <b>Exception Details: </b>System.FormatException: Input string was not in a correct format.<br> <br> <b>Source Error:</b> <br> <br> <table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td> <pre>Line 6: &lt;MetadataType(GetType(Series_Master_Best_Cost))&gt; _<br>Line 7: Partial Public Class [Series_Master_Best_Cost]<br><font color="red">Line 8: Dim DisplayColumn(&quot;USER_MASTER&quot;, &quot;USER_MASTER&quot;, False)<br></font>Line 9: Public Class [Series_Master_Best_Cost]<br>Line 10: </pre> </td> </tr> </tbody> </table> <br> <b>Source File: </b>D:\Intranet\BestCost\App_Code\Series_Master_Best_Cost.vb<b> &nbsp;&nbsp; Line: </b>8&nbsp; </font><br> <p></p> 2008-11-26T14:05:05-05:002769608http://forums.asp.net/p/1196276/2769608.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Got the error to go away.&nbsp; Found some information on http://msdn.microsoft.com/en-us/library/cc679189.aspx that showed a little different information, but still is not sorting my column.&nbsp; I am guessing it is now a matter of me not having the right information in each of the parameters, classes, or types.</p> <p>This is my partial class file: <br> </p> <p>Imports Microsoft.VisualBasic<br> Imports System.Web.DynamicData<br> Imports System.ComponentModel<br> Imports System.ComponentModel.DataAnnotations<br> <br> <br> &lt;MetadataType(GetType(Series_Master_Best_Cost))&gt; _<br> Partial Public Class Series_Master_Best_Cost<br> <br> &nbsp;&nbsp;&nbsp; &lt;DisplayColumn(&quot;USER_MASTER&quot;, &quot;USER_MASTER&quot;, False)&gt; _<br> &nbsp;&nbsp;&nbsp; Public Class Series_Master_Best_Cost<br> <br> &nbsp;&nbsp;&nbsp; End Class<br> End Class</p> <p>Is there something else that I am missing?</p> <p>I also tried 'Series_Master_Best_CostMD'&nbsp; in the MetadataType and Public Class (not Partial), which seemed to follow what others had done, but then it said that the type was not defined.<br> </p> <p>What is the difference between DisplayColumnAttribute and DisplayColumn...they seem to both be used in that page referenced above. <br> </p> <p>Anything else you can tell me?</p> <p>Thanks, Ann <br> </p> 2008-11-26T14:31:25-05:002769980http://forums.asp.net/p/1196276/2769980.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Imports Microsoft.VisualBasic<br> Imports System.Web.DynamicData<br> Imports System.ComponentModel<br> Imports System.ComponentModel.DataAnnotations<br> <br> <br> &lt;MetadataType(GetType(Series_Master_Best_Cost))&gt; _<br> &lt;DisplayColumn(&quot;USER_MASTER&quot;, &quot;USER_MASTER&quot;, False)&gt; _<br> Partial Public Class Series_Master_Best_Cost<br> <br> &nbsp;&nbsp;&nbsp; Public Class Series_Master_Best_Cost<br> <br> &nbsp;&nbsp;&nbsp; End Class<br> I think it should be more like this the table level attributes on the partial class.</p> 2008-11-26T17:27:27-05:002770076http://forums.asp.net/p/1196276/2770076.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>&nbsp;Has anyone else been able to get this to work?&nbsp; I have changed it as suggested (and closed the second class too), and it still does not sort the filtered list...or anything else for that matter...</p> <p>There must be something other than this that I am not getting done.</p> <p>While I am a novice, it seems to me that this is trying to sort the COLUMN &quot;user_master&quot;, not the filtered dropdown list, but that isn't sorted either...</p> <p>&nbsp;This wouldn't be such a big issue, but we have thousands of employees in our company and trying to find one of them in an unsorted list is not possible!</p> <p>&nbsp;Any help would be great!</p> <p>HAPPY THANKSGIVING TO ALL!!!</p> <p>Thanks, Ann <br> </p> <p>&nbsp; <br> </p> 2008-11-26T18:14:31-05:002770263http://forums.asp.net/p/1196276/2770263.aspx/1?Re+Dynamic+filter+order+byRe: Dynamic filter order by <p>Maybe an example will help; let's assume that your model generates the folowing classes&nbsp;(sorry for using C# syntax):</p> <pre class="prettyprint">public partial class Product { public Category MyCategory; } public partial class Category { public string Name; public int Code; }</pre> <P>Now say you are displaying&nbsp;your Products list. Since&nbsp;Product has a foreign key reference to Category,&nbsp;a&nbsp;filter in the form of a drop-down&nbsp;will be generated&nbsp;for the MyCategory column. I am assuming now that you want to customize the order in which the items appear in this dropdown. If you are trying to do something different, please clarify.</P> <P>So to customize this ordering, you would decorate&nbsp;the Category class (since this is the type of the MyCategory property on Product) with DisplayColumnAttribute, initialized as follows:</P><pre class="prettyprint">[DisplayColumnAttribute(<SPAN class=st>"Name"</SPAN>, <SPAN class=st>"Code"</SPAN>, <SPAN class=kwd>true</SPAN>)] <SPAN class=kwd>public</SPAN> partial <SPAN class=kwd>class</SPAN> Category { }</pre> <p>This will cause Dynamic Data&nbsp;to display the values in the dropdown using the value of the Name&nbsp;property, but they will be ordered in descending order based on the Code property.</p> <p>As was noted earlier, you would add it in code to your App_Code folder (if in a WebSite project) or just as a class anywhere inside of a Web Application project. Since this is a class-level attribute, you don't need to use MetadataTypeAttribute.</p> <p>You asked about the difference between [DisplayColumnAttribute] and [DisplayColumn]. There is none. The compiler automatically infers that if you have [DisplayColumn] you actually mean [DisplayColumnAttribute]. Note that this behavior only applies to attributes when they are used to decorate code (and not ones instantiated in code).</p> 2008-11-26T19:59:53-05:00