Sorting in master-details scenario

4 posts, 0 answers
  1. Richard
    Richard avatar
    8 posts
    Member since:
    Sep 2008

    Posted 31 Jul 2010 Link to this post

    I added two grid contols to a form and tried to bind them to a datasource.
    Therefore I used a BindingSource object bound to a List object returned from function GetMasterObjects.
    This function uses LINQ for retrieving the data. So sorting the master data is not a problem.

    _bndsrc_Master = New BindingSource(_blView.GetMasterObjects(_scope), "")

    The Master class holds a Details list.

    [Telerik.OpenAccess.FieldAlias("details")]
    public IList<Detail> Details
    {
    get { return details; }
    }

    When I bind the second grid to the details list, the rows are unsorted.

    _bndsrc_Details = New BindingSource(_bndsrc_Master, "Details")

    So I extended my class and added a List property based on IList details, but this list wasn't correctly synchronized.

    Perhaps there is a simple solution for sorting the Details data, but I can't find it.

    Thanks for help in advance

    Richard

     

  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 03 Aug 2010 Link to this post

    Hello Richard,

    You can provide a custom property for the Details collection which returns the ordered list:

    public List<Detail> OrderedDetails
    {
        get
        {
            List<Detail> orderedDetails = null;
            if (this.details == null)
            {
                orderedDetails = this.Details.OrderBy(c => c.Name).ToList();
            }
            return orderedDetails;
        }
    }

    The custom property is ordered by Name. Now you could bind the details grid control to the OrderedDetails property instead of the Details one.
    If you have any questions, please feel free to contact us.

    Best wishes,
    Damyan Bogoev
    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
  3. DevCraft banner
  4. Richard
    Richard avatar
    8 posts
    Member since:
    Sep 2008

    Posted 05 Aug 2010 Link to this post

    Hi Damyan,

    to create the ordered list is not the problem. The problem is the synchronization of the details list when the master row changes.

     

    _bndsrc = New BindingSource((From v As Master In _scope.Extent(Of Master)() Order By v.Name Select v).ToList, "")
    tdbgMaster.SetDataBinding(_bndsrc, "")
    tdbgDetails.SetDataBinding(_bndsrc, "OrderedDetails")

       vs.

    tdbgDetails.SetDataBinding(_bndsrc, "Details")

    When the databinding is set to Details and I click a row in my master grid, the details grid is synchronized correctly.
    If bound to OrderedDetails no synchronization takes place. It seems that a change notification is missing.

    So there seems to be a difference in change notification between the standard TrackedList and the List object.

    Regards
    Richard Kling
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 11 Aug 2010 Link to this post

    Hi Richard,

    You could either apply the provided logic for the OrderedDetails list for the Details list property or append the following attribute to the OrderedDetails property:

    [Telerik.OpenAccess.FieldAlias("details")]

    Hope that helps.


    Sincerely yours,
    Damyan Bogoev
    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
Back to Top