private void crashRowEditComplete(object sender, GridViewRowEditEndedEventArgs e) |
{ |
if (e.EditAction == GridViewEditAction.Commit |
&& e.EditOperationType == GridViewEditOperationType.Insert) |
{ |
ApplicationState.Carrier.Crashes.Add((Crash)e.NewData); |
ApplicationState.Carrier.Drivers.Add(((Crash)e.NewData).Driver); |
ApplicationState.Carrier.Vehicles.Add(((Crash)e.NewData).Vehicle); |
crashListGrid.SelectedItem = e.NewData; |
} |
} |
/// <summary> |
/// Satisfies req for IPartnerMessenger. Dynamically Loads Partner radtab content. |
/// </summary> |
/// <param name="PartnerType"></param> |
/// <param name="partner"></param> |
public void NotifyPartnerSelection(Type PartnerType, Partner partner) |
{ |
if (PartnerType == typeof(EmailPartner)) |
{ |
this._selectedPartner = (EmailPartner)partner; |
this.PartnerRadTabItem.SetValue(RadTabItem.ContentProperty, new EmailPartnerView(this, (EmailPartner)partner)); |
} |
else if (PartnerType == typeof(NamedCallPartner)) |
{ |
this._selectedPartner = (NamedCallPartner)partner; |
this.PartnerRadTabItem.SetValue(RadTabItem.ContentProperty, new NamedCallPartnerView(this, (NamedCallPartner)partner)); |
} |
else if (PartnerType == typeof(AnonymousCallPartner)) |
{ |
this._selectedPartner = (AnonymousCallPartner)partner; |
this.PartnerRadTabItem.SetValue(RadTabItem.ContentProperty, new AnonymousCallPartnerView(this, (AnonymousCallPartner)partner)); |
} |
else |
ClientErrorHelper.ShowError(new Exception("Stuff went wrong")); |
} |
I have tried it as just setting the content property directly as well. Basically it works for the first assignment to the content property and then all other setting attempts although the radtabitem.content property changes, the user control displayed in the tab does not change.
I’m using a generic item wrapper defined as below:
public class ItemWrapper
{
public State State { get; set; }
public string Message { get; set; }
public object Item { get; set; }
}
public enum State
{
Ok,
Warning,
Error
}
The ItemWrapper could contain objects from different classes in the Item property; for instance:
ItemWrapper wrapper = new ItemWrapper();
wrapper.Item = new Company() {Id = "Acme", Desc="Acme company" };
The point is how to bind RadGridView columns to show both ItemWrapper columns (State and Message) and wrapped object columns ( Company.Id and Company.Desc).
Binding ItemWrapper properties is ok while the expected way for Company should be:
col.DataMemberBinding = new Binding("Item.Id");
col.DataType = typeof(string);
that seems, at least, to work but raising lot of exceptions:
A first chance exception of type 'System.ArgumentException' occurred in Telerik.Windows.Data.dll
that slow down rows loading to several second for few items (making control unusable) .
Sincerely
I need to be able to filter the RadGridView based on a collection property on each item. Here is a sample to illustrate my case. Let’s suppose that each item in the grid is of type Person and each person has a collection property ScheduledMeetings. I need to apply some kind of filter that does the following:
People.Where(p => p. ScheduledMeetings.Contains(someMeeting))
which will return all people participating in the specified meeting.
The documentation samples all use the built-in CreateFilterExpression method of the FilterDescriptor class. So my first choice was to use the existing FilterDescriptor class in combination with FilterOperator.Contains but it seems that ‘Contains’ only works with strings and not with IEnumerable (even with FilterDescriptor.MemberType specified)!
I suppose I need to implement some custom FilterDescriptor class inheriting from FilterDescriptorBase and then provide the Expression from the CreateFilterExpression override. But how do I create such expression?