Do you have an example of creating a custom list editor for Blazor please?
I am trying to bind DxPivotGrid to a list of a simple class I defined as an example.
C#public class ResultObject : IXafEntityObject, IObjectSpaceLink, INotifyPropertyChanged
{
public ResultObject()
{
// In the constructor, initialize collection properties, e.g.:
// this.AssociatedEntities = new List<AssociatedEntityObject>();
}
[Browsable(false)] // Hide the entity identifier from UI.
public Int32 ID { get; protected set; }
// You can use the regular Code First syntax:
public string Name { get; set; }
public string Name0 { get; set; }
public string Name1 { get; set; }
public string Name2 { get; set; }
public string Name3 { get; set; }
public double V1 { get; set; }
public double V2 { get; set; }
public double V3 { get; set; }
#region IXafEntityObject members (see https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppIXafEntityObjecttopic.aspx)
void IXafEntityObject.OnCreated()
{
// Place the entity initialization code here.
// You can initialize reference properties using Object Space methods; e.g.:
// this.Address = objectSpace.CreateObject<Address>();
}
void IXafEntityObject.OnLoaded()
{
// Place the code that is executed each time the entity is loaded here.
}
void IXafEntityObject.OnSaving()
{
// Place the code that is executed each time the entity is saved here.
}
#endregion
#region IObjectSpaceLink members (see https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppIObjectSpaceLinktopic.aspx)
// Use the Object Space to access other entities from IXafEntityObject methods (see https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113707.aspx).
private IObjectSpace objectSpace;
IObjectSpace IObjectSpaceLink.ObjectSpace
{
get { return objectSpace; }
set { objectSpace = value; }
}
#endregion
#region INotifyPropertyChanged members (see http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx)
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
This is as far as I got in my attempt to create the Custom List editor:
C#using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BlazorCoreSol.Module.BusinessObjects.DataModel;
using DevExpress.Blazor;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Utils;
namespace BlazorCoreSol.Module.Blazor.Editors
{
[ListEditor(typeof(ResultObject))]
public class BlazorResultListEditor : ListEditor
{
public BlazorResultListEditor(IModelListView info) : base(info) { }
private DxPivotGrid<ResultObject> control;
public override SelectionType SelectionType => throw new NotImplementedException();
protected override object CreateControlsCore()
{
control = new DxPivotGrid< ResultObject>();
return control;
}
protected override void AssignDataSourceToControl(Object dataSource)
{
DxPivotGridDataProvider<ResultObject> PivotGridDataProvider = DxPivotGridDataProvider<ResultObject>.Create<IList<ResultObject>>(ListHelper.GetList(dataSource) as IList<ResultObject>);
if (control != null)
{
control.Data = .AsQueryable< ResultObject>();
}
}
public override void Refresh()
{
}
private object focusedObject;
public override object FocusedObject
{
get
{
return focusedObject;
}
set
{
focusedObject = value;
}
}
public override IList GetSelectedObjects()
{
List<object> selectedObjects = new List<object>();
if (FocusedObject != null)
{
selectedObjects.Add(FocusedObject);
}
return selectedObjects;
}
}
}
Thank you
Hi Philip,
At present, we don't have an example of how to create a custom List Editor in XAF Blazor. We recommend using custom Razor components for this. This approach is illustrated at:
Thank you for the references. I managed to get a little further and now have a running mini-application. Unfortunately, I cannot figure out how to assign a data source to the actual control.
I have attached the project.
protected override void AssignDataSourceToControl(Object dataSource) { DxPivotGridDataProvider<ResultObject> PivotGridDataProvider = DxPivotGridDataProvider<ResultObject>.Create<IList<ResultObject>>(ReturnData(dataSource)); if (control != null) { control.Data = PivotGridDataProvider.PivotGridDataSource; } }
It would be fantastic if it were possible to figure out how to integrate the PivotGrid in XAF Blazor since this is the remaining blocker preventing us from using Blazor for our application.