locked
Order FilterRepeater controls RRS feed

  • Question

  • User1324974859 posted

    I'm wondering if there is any way to alter the order of the controls returned by a filter repeater.  I could use individual filter controls and probably will have to, but I'm searching for a dynamic solution.  Currently, the controls are returned in alphabetical form.  It might make more logical sense if the controls were ordered in ascending order by the number of foreign keys in the association. I tried prepending association member names with 1's and 2's etc. to affect the order, but never managed to come out with a useable set of app_code files, even with my best regex attempts. I also tried to change the tabindex field for FilterRepeaterItems in FilterRepeater_PreRender but it's read only.

    Saturday, December 20, 2008 9:59 AM

Answers

  • User-1005219520 posted

    The FilterAttribute doesn't seem to currently take the order arguement, but you can use the Dislay attribute to order the column and the filters. I verified the Display attribute works  

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.DataAnnotations;
    using System.Web.DynamicData;
    
    namespace DynamicDataProject {
    
        [MetadataType(typeof(Product_MD))]
        public partial class Product {
    
            private class Product_MD {
                [FilterUIHint("MultiForeignKey")]
                public object Category { get; set; }
                [FilterUIHint("BooleanRadio")]
                public object Discontinued { get; set; }
                [FilterUIHint("Range")]
                [Range(0,150)]
                public object UnitsInStock { get; set; }
                [Display(Order=-1)]    // without the Order = -1, Supplier is last, -1 makes it first
                [FilterUIHint("Autocomplete")]
                public object Supplier { get; set; }
            }
        }
    }
    
     works.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 20, 2008 6:51 PM

All replies

  • User-1005219520 posted

    The released version does not have the ability to order FR controls - but the  ASP.NET Dynamic Data 4.0 Preview 2 Samples does.

    See DynamicDataVNextSamples\DynamicDataFuturesSample\NorthwindPartials.cs and the Filter attribute (which take a weight argument). In the example

    All the examples have the order argument commented out, perhaps order did not make it into the preview 2. I believe it's scheduled for the next release.

     

                // Display the Discontinued filter using the BooleanRadio.ascx filter control
                // Make sure the Discontinued filter is displayed first
                // This is currently disabled
                [Filter(FilterControl = "BooleanRadio")]//, Order = -1)]
                public object Discontinued { get; set; }
     
     
    Saturday, December 20, 2008 5:36 PM
  • User-1005219520 posted

    The FilterAttribute doesn't seem to currently take the order arguement, but you can use the Dislay attribute to order the column and the filters. I verified the Display attribute works  

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.DataAnnotations;
    using System.Web.DynamicData;
    
    namespace DynamicDataProject {
    
        [MetadataType(typeof(Product_MD))]
        public partial class Product {
    
            private class Product_MD {
                [FilterUIHint("MultiForeignKey")]
                public object Category { get; set; }
                [FilterUIHint("BooleanRadio")]
                public object Discontinued { get; set; }
                [FilterUIHint("Range")]
                [Range(0,150)]
                public object UnitsInStock { get; set; }
                [Display(Order=-1)]    // without the Order = -1, Supplier is last, -1 makes it first
                [FilterUIHint("Autocomplete")]
                public object Supplier { get; set; }
            }
        }
    }
    
     works.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 20, 2008 6:51 PM
  • User1324974859 posted

    Hey Rick, 

    Thanks for writing, esp. on a weekend.  I had already bookmarked and studied your articles Improving the FK display http://blogs.msdn.com/rickandy/archive/2008/11/22/improving-the-fk-field-display-showing-two-fields-in-foreign-key-columns-with-ef.aspx and Tweaking the Filter Repeater http://blogs.msdn.com/rickandy/archive/2008/09/25/tweaking-the-filter-repeater.aspx, both excellent. I appreciated that you took the extra mile to write the code in VB in those articles, too.  I have been using the DD preview 2 but can't port your suggestion for metacolumn markup to VB and get it working.   I tried this:

     <Display(Order=-1),FilterUIHint("ForeignKey")> _ 
     Public Property MyFK() As Object
            Get
                Return _MyFK       
     End Get
            Set(ByVal value As Object)
                _MyFK = value
            End Set
        End Property

     

     



     

    Saturday, December 20, 2008 9:23 PM
  • User1324974859 posted

    Doh!  It works.  I left out a colon

    <Display(Order:=-1),FilterUIHint("ForeignKey")> _ 
     Public Property MyFK() As Object
            Get
                Return _MyFK       
     End Get
            Set(ByVal value As Object)
                _MyFK = value
            End Set
        End Property

    Thanks again.

    Sunday, December 21, 2008 10:13 AM
  • User-1005219520 posted

     Good job. Thanks for posting your solution.

    Monday, December 22, 2008 1:35 PM