This is a migrated thread and some comments may be shown as answers.

Sorting in master-details scenario

3 Answers 55 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard
Top achievements
Rank 1
Richard asked on 31 Jul 2010, 05:16 PM

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

 

3 Answers, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 03 Aug 2010, 07:06 PM
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
0
Richard
Top achievements
Rank 1
answered on 05 Aug 2010, 10:01 AM
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
0
Damyan Bogoev
Telerik team
answered on 11 Aug 2010, 08:20 AM
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
Tags
Development (API, general questions)
Asked by
Richard
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Richard
Top achievements
Rank 1
Share this question
or