binding converters and sorting/filtering

18 posts, 1 answers
  1. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 16 Nov 2009 Link to this post

    Is there anyway to enable sorting and filtering on a column with a binding converter ...
    like so

    <telerikGridView:RadGridView x:Name="ItemListGrid"  Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True" Margin="0,0,0,0" ItemsSource="{Binding Data, ElementName=ddsItemList}" CanUserInsertRows="False"  > 
        <telerikGridView:RadGridView.Columns> 
            <telerikGridView:GridViewDataColumn Header="Manufacturer" DataMemberBinding="{Binding ManfMaster.NameManf}" Width="Auto" /> 
            <telerikGridView:GridViewDataColumn Header="PartNumber" DataMemberBinding="{Binding ManfNo}" Width="Auto" /> 
            <telerikGridView:GridViewDataColumn Header="Description" DataMemberBinding="{Binding ItemMaster.ZDesc}" Width="Auto" TextAlignment="Left"/>  
            <telerikGridView:GridViewDataColumn Header="Min Level" DataMemberBinding="{Binding . ,Converter={StaticResource ItemListMinLevel} }" Width="Auto" TextAlignment="Right"/>  
            <telerikGridView:GridViewDataColumn Header="Max Level" DataMemberBinding="{Binding . ,Converter={StaticResource ItemListMaxLevel} }" Width="Auto" TextAlignment="Right"/>  
            <telerikGridView:GridViewDataColumn Header="MSD Level" DataMemberBinding="{Binding MsdLevelMaster,Converter={StaticResource ItemListMSDLevel} }" Width="Auto" TextAlignment="Left"/>  
        </telerikGridView:RadGridView.Columns> 
    </telerikGridView:RadGridView> 
     

    Unfortunately i am using the ria domain data source and the pager .

    So as far as i know i cannot wrap the objects being returned by the domain data source
    Unless I suppose i do it on the server side in the query

    The converted columns are used to expose nested object propertys with special needs (lol). 

    Any help would be appreciated.

    thanks
    dco

  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Nov 2009 Link to this post

    Hello,

    Converters are only for UI purposes and since the grid will perform these operations on the data-source level this cannot be achieved. We have plans however to provide calculated column (in Q1 2010) with support for grouping, filtering, sorting, etc. similar to our ASP.NET grid.

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 16 Nov 2009 Link to this post

    Thought as much.
    Was hoping for something super creative or super secret (lol). 

    thanks anyway vlad
    dco
  5. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 04 Jun 2010 Link to this post

    Any update on the binding converter column sort/filtering?
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 08 Jun 2010 Link to this post

    Hi Jane,

    As Vlad said, the data engine of RadGridView can not perform operations on  UI objects such as binding converters.

    What can be done here is to expose the converted value via property of your business object and use the SortMember path of the column to redirect sorting logic to the new property ( containing the converted value )

    All the best,
    Pavel Pavlov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 08 Jun 2010 Link to this post

    Pavel, Thank you for your reply. I am new to the silverlight. Can you send me a project to demo it?
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 10 Jun 2010 Link to this post

    Hi Jane,

     
    I would be happy to provide you with a sample project but first can you please give me more details about your requirements so that my example is as close as possible to your case.

    Regards,
    Maya
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 11 Jun 2010 Link to this post

    Pavel,
    I am using ria service EFW, on the page

     

     

    private ObservableCollection<PwrSmartService.Web.Computer> computeritemsSource;

     

     

     

    public PagedCollectionView result = null;

    For load data:

     

     

     

     

    var computerQuery = this.myDomainContext.GetComputersByGroupIDQuery(G.GroupID);

     

     

     

    var loadOperation = this.myDomainContextLoad(computerQuery, LoadBehavior.RefreshCurrent, true);

     

    loadOperation.Completed += (sender1, args) =>

    {

     

     

    if (loadOperation.HasError)

     

     

     

    ErrorHandler.HandleOperationError("Err", loadOperation);

     

     

     

    else

     

     

     

     

     

    {

     

     

    if (radGridViewComputer != null)

     

    {

    computeritemsSource =

     

    new ObservableCollection<PwrSmartService.Web.Computer>(loadOperation.Entities);

     

    result =

     

    new PagedCollectionView(computeritemsSource);

     

    result.PageSize = GridPageSize;

    radGridViewComputer.ItemsSource = result;

    radGridViewComputer.SelectedItems.Clear();

    RadDataPagerComputer.Source = result;

    }

    }

     

     

     

    so  on my Radgridview I need to display some column by passing computer
    Here is my converter code

     

     

    public class ComputerActivePwrSchemeConverter : IValueConverter

     

    {

     

     

     

    #region

     

     

    IValueConverter Members

     

     

     

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

     

    {

     

     

    Computer c = value as Computer;

     

     

     

    String sRet = "";

     

     

     

    if (c != null)

     

    {

     

     

    foreach (vw_ComputerActivePowerConfigs vwActive in myContext.vw_ComputerActivePowerConfigs)

     

    {

     

     

    if (vwActive.ComputerID == c.ComputerID)

     

    {

    sRet = vwActive.SchemeName;

     

     

    return sRet;

     

    }

     

    return sRet;

     

    }

     

     

    else return value;

     

    }

     

     

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

     

    {

     

     

    throw new NotImplementedException();

     

    }

    #endregion

    }

    on xmal

     

     

     

    <telerikGridView:GridViewDataColumn x:Name="ActiveSchemeColumn" DataMemberBinding="{Binding Converter={StaticResource ComputerActivePwrSchemeConverter}}" Header="Active Scheme" Width="Auto"/>

     

     

    }

    This column doest not has sort or filter now.

    Thank you for your help.

  10. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 17 Jun 2010 Link to this post

    Hi Jane,
    Since in your case modifying the business object is limited by RIA , I may suggest a slightly different approach .

    It is demonstrated in the sample attached.

    On a click on the column header RadGridView would sort either by the original value , or by the converted value depending on the user selection.

    This is achieved by handling the RadGridView.sorting event and performing own sorting logic when the user clicks on column headers.

    Regards,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 29 Aug 2010 Link to this post

    Hello Vlad,
    I was looking for the calculated column... Has it been added?

    In my RIA WCF services I added a calculated field to one of my entity like that:
    using System.Runtime.Serialization;
    namespace AWeb
    {
        public partial class ProgramDetail
        {
            [DataMember]
            public string FormattedShowName
            {
                get
                {
                    if (string.IsNullOrWhiteSpace(this.ShowName))
                    {
                        return this.Title;
                    }
                    else
                    {
                        return string.Format("{0} S{1:00}E{2:00}", this.ShowName, this.Season, this.Episode);
                    }
                }
                set { }
            }
        }
    }

    When I try to use that column in a group using drag and drop, I get the following error:
    ---------------------------
    Program List Load Error
    ---------------------------
    System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetProgramDetailByTypes'. The specified type member 'FormattedShowName' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
    ---------------------------
    OK  
    ---------------------------

    I understand the error, the real entity used in the linq sort query does not find the property, but so the operation still works, the rows are correctly grouped by that column I guess there might be something to do so that I don't get the exception.

    And that solution might be a special calculated column that handles such cases... Has this been added?

    Also, I tryed to use the SortPathMember property to redirect the sort operation but this has no effect on my grouping problem.

    Any hints on how to proceed except handling the sort by myself ?

    Thanks a lot for your help,
    John.


     

  12. Nick
    Nick avatar
    19 posts
    Member since:
    Aug 2010

    Posted 29 Aug 2010 Link to this post

    Why don't you just add an entry to the DomainService class on the .Web project end?

    Let's say you have an entity called "User", and that entity has 2 properties, "Name", "BirthDate", and you want to have a property called "Age".
    Just create a new Class like:

    [Serializable()]
    public class UserWithMetaData
    {
        [Key]
        public String Name { get; set; }
        public DateTime BirthDate { get; set; }
        public double Age { get; set; }
    }

    In your DomainService class, just add something like:

    [Query(IsDefault = true)]
    public List<UserWithMetaData> GetUsersWithMetaData()
    {
        List<UserWithMetaData> Result = new List<UserWithMetaData>();
        foreach (var e in GetUsers().OrderBy(e => e.Name))
        {
            Result.Add(new UserWithMetaData()
            {
                Name = e.Name,
                BirthDate = e.BirthDate,
                Age = DateTime.Now.Subtract(e.BirthDate).TotalDays / 365
            });
        }
        return Result;
    }

    Good Luck!
  13. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 29 Aug 2010 Link to this post

    Hello nick,
    Thanks for jumping in...
    You are right this can be a workaround...
    In fact thanks for suggesting it. Without real solution I might end using this.

    Just, I find this is too much of an overhead. To achieave the same result I need an extra class and I need to copy tha data from one list to another when I could just live with my solution if it would integrate in the grid with something like a Calculated column.
    Also I must have missed somthing as using a partial class seems to be the recomended way of extending an entity used in RIA WCF Services... I may prove wrong...

    Any other hints?
    Thanks anyway...

    John. 
  14. Joel
    Joel avatar
    41 posts
    Member since:
    Nov 2010

    Posted 05 Jan 2012 Link to this post

    "We have plans however to provide calculated column (in Q1 2010) with support for grouping, filtering, sorting, etc. similar to our ASP.NET grid."

    Did anything ever happen with this?  I agree this problem can be solved with a local view model, but I would rather the grid took care of it.  That would allow me to keep using the service generated objects without having to build a mostly identical middle man.

    At the very least, the filter could run the value through the convertback function of the converter before it performed the filtering.
  15. Joel
    Joel avatar
    41 posts
    Member since:
    Nov 2010

    Posted 06 Jan 2012 Link to this post

    I think this is called a calculated column for the other platforms, but it ended up being called the expression column for silverlight.  It's there now, but it doesn't natively support any of the filtering that comes with the regular columns, so beware.
  16. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 06 Jan 2012 Link to this post

    Hi,

    Grouping and sorting is already supported in our expression column and we will add filtering support with our upcoming Q1 2012 (middle of February). 

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  17. Bob
    Bob avatar
    46 posts
    Member since:
    Apr 2012

    Posted 12 Sep 2012 Link to this post

    Hi Vlad,

    Based on your previous post in this thread, dated Jan 6, 2012:

    Is sorting and filtering of converter based columns supported yet in the latest release of Silverlight 5 RadControls?

    I ask this because, using the built-in filter dialog, we are only able to get the Contains option to filter converter based columns.

    Thanks...Bob Baldwin
    Trabon Solutions
  18. CrankyOldSkool
    CrankyOldSkool avatar
    3 posts
    Member since:
    Oct 2011

    Posted 29 May 2014 in reply to Bob Link to this post

    "Hi, Grouping and sorting is already supported in our expression column and we will add filtering support with our upcoming Q1 2012 (middle of February). 

    Regards,
     Vlad

    the Telerik team"

    Did this ever make it into the Silverlight Controls for Silverlight 5?
  19. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Jun 2014 Link to this post

    Hello,

    Yes, we added filtering support with GridViewExpressionColumn. You can check the Calculated Column demo on how the sorting, grouping and filtering functionality is supported.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
DevCraft banner