| Author |
Share Topic Topic Search Topic Options
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Topic: [Resolved]Accessing current DetailGrid object??????? Posted: 04-Jan-2008 at 8:41am |
I take that back it doesn't work.
Source was inaccurate:
Edited by orcities - 04-Jan-2008 at 8:51am
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 04-Jan-2008 at 8:25am |
As an FYI I found this but can't not sure how to implement it.
This is suppose to get rid of hte problem.
public override object BuildUp(IBuilderContext context, Type t, object existing, string id) { DependencyResolutionLocatorKey result = new DependencyResolutionLocatorKey(t, id); ITypeMappingPolicy policy = null; if (t.IsGenericType) { Type genericType = t.GetGenericTypeDefinition(); policy = context.Policies.Get<ITypeMappingPolicy>(genericType, id); } else { policy = context.Policies.Get<ITypeMappingPolicy>(t, id); } if (policy != null) { result = policy.Map(result); //TraceBuildUp(context, t, id, Properties.Resources.TypeMapped, result.Type, result.ID ?? "(null)"); //Guard.TypeIsAssignableFromType(t, result.Type, t); } return base.BuildUp(context, result.Type, existing, result.ID); }
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 3:38pm |
I have GreyGrid copied from DevExBasicGridView. I have it in the correct namespace.
Only change is the name of the class.
I have registered as follows:
RegisterViewType<Views.GreyGridView>(LOC.CEMS.Interface.Constants.ViewNames.GreyGridView)
Implemented as follows:
CreateGridViewContext();
pContext.GridViewId = GridViewId;
ViewFactory.AddNew(LOC.CEMS.Interface.Constants.ViewNames.GreyGridView, WorkItem, GridViewId, typeof(ContactAddress));
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 3:33pm |
I went through and double checked and even re-did all my references. I still get the same error. Even when I have it in conjuction to the BasicGrid.
|
 |
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 3:13pm |
If it isn't already, make sure that your GregGridView is an exact copy (except for the name and namespace) of DevExBasicGridView (including injecting DevExGridViewPresenter).
I trust you've changed the namespace and class name in the .designer.cs file as well.
You could also try registering your view under a different name, then calling
ViewFactory.AddNew<GreyGridView>("newname", WorkItem, typeof(entity));
Bill J.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 12:35pm |
One more correction.
The first time to BuildUp it has type as GreyGridView then second time, after calling base.BuildUp it is System.Type.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 12:14pm |
A little more indepth.
ViewFactory.AddNew calls SmartPart.AddNew going to the ObjectBuilder.TypeOnlyMappingStrategy.BuildUp which throws the error when calling base.BuildUp.
The parameter result.Type becomes System.Type for some reason.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 03-Jan-2008 at 12:10pm |
That makes more sense but I still get an error in the TypOnlyMappingStrategy.BuildUp:
Excpetion: Can not create an instance of type 'System.Type'.
Inner Exception: Cannot create an abstract class.
This comes at the point where I add the Grid using:
ViewFactory.AddNew(ViewNames.BasicGrid....) in the Page or Tab Controller.
|
 |
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 4:00pm |
OK, you're right. I'm working with a newer version in which Ward has done some major refactoring. Please accept my apologies.
Looking back at 2.3.0.1 in our source code repository, DevExBasicGridView does indeed use DevExGridViewPresenter.
So you're on exactly the right track.
1. You'll need your own view (the more I think of it, it's probably best to copy DevExBasicGridView and inherit from DevExGridView) and register it instead of the standard DevExGridView.
2. Make your LOCGridViewPresenter inherit from DevExGridViewPresenter. Inject it into your grid view.
3. Override AddDetailGrid() in LOCGridViewPresenter to create a LOCDetailGridViewBuilder that inherits from the standard DevExDetailGridViewBuilder.
4. In your detail grid view builder, capture the detail binding manager in the detail view context.
Sorry for the version confusion.
Bill J.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 2:33pm |
I see GridViewPresenterBase but not GridViewPresenter. Method is not defined in GridViewPresenterBase.
I did a search of the entire solution and could not find the method.
I am using Cabana 2.3.0.1
[InjectionMethod]
public void InjectPresenter([CreateNew]IdeaBlade.Cab.UI.Views.GridViewPresenterBase<IBindingView> pPresenter) {
SetPresenter(pPresenter);
}
I have also tried:
public void InjectPresenter([CreateNew]LOCGridViewPresenter<IBindingView> pPresenter)
|
 |
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 2:26pm |
Where is DevExGridViewPresenter defined? (I see that it's defined because of its color in your code sample). My version of DevExBasicGridView uses the common GridViewPresenter. SetDetailGridViewBuilder() is defined in that class.
The "new" keyword should only be required if you're injecting the same presenter type as the base class.
Try changing the presenter type first.
If the error persists, try going back to a full copy of DevExBasicGridView that inherits from DevExGridView and we'll try to understand the "Cannot create and abstract class" error.
Bill J.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 2:23pm |
|
This is iritating the crap out of me. All I have basically done is rename the same file and unregister the basic grid and register my basic grid. Why in the world will it now work.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 2:04pm |
|
5. pPresenter.SetDetailGridViewBuilder() doesn't exist.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 1:40pm |
1. Shown below
2. Done
3. I am using the DevExGridViewPresenter just to make sure it works.
4. No warning. New keyword is in the Presenter [CreateNew]?
5. The error occurrs in the TypeOnlyMappingStratey.BuildUp
6. That is where it is.
[SmartPart]
public partial class GreyGridView : DevExBasicGridView{
#region Ctor
/// <summary>Ctor with BoundType.</summary>
/// <remarks>Useful when setting the BoundType before ObjectBuilder builds out the view.</remarks>
public GreyGridView(Type pBoundType)
: base(pBoundType) {
}
#endregion
/// <summary>
/// Set the presenter by injection.
/// </summary>
[InjectionMethod]
public void InjectPresenter([CreateNew]DevExGridViewPresenter<IBindingView> pPresenter) {
SetPresenter(pPresenter);
}
}
|
 |
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 1:22pm |
Hi Dan,
1. You should be inheriting from DevExBasicGridView.
2. You should only need the public constructor. In it, just call the base constructor accepting the bound type and let the base class manage the bound type.
3. I notice you're injecting a presenter of type DevExGridViewPresenter. Is this yours? You should be able to get by with the standard "GridViewPresenter".
4. You should get a warning that your InjectPresenter method hides the base class method. Place the "new" keyword on your method.
5. Then, after the SetPresenter() call, just call pPresenter.SetDetailGridViewBuilder(new MyDetailGridBuilder(GridBindingManager))
6. Does the "An item with the same key has already been added" exception occur on the RegisterViewType() call in your foundation module? Where in the foundation did you put these? They should be in the ViewFactoryService override of RegisterInitialViewType().
Bill J.
|
 |
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 02-Jan-2008 at 10:14am |
I take that back I was doing it wrong. Now that I have corrected it I am getting the following error:
An item with the same key has already been added. (when inheriting DevExBasicGrid)
and
{"Cannot create an abstract class."} (When inheriting DevExGridView
Not sure why I have not changed anything other then Inheriting and the registering my version.
My GridView:
namespace LOC.CEMS.Foundation.Views
{
/// <summary>View of a DevEx XtraGrid and DotNet BindingNavigator bound to a Type.</summary>
[SmartPart]
public partial class GreyGridView : DevExGridView, IBindingView{
#region Ctor
/// <summary>Injection Ctor.</summary>
private GreyGridView() {
InitializeComponent();
}
/// <summary>Ctor with BoundType.</summary>
/// <remarks>Useful when setting the BoundType before ObjectBuilder builds out the view.</remarks>
public GreyGridView(Type pBoundType)
: this() {
SetBoundType(pBoundType);
}
private void SetBoundType(Type pBoundType){
BoundType = pBoundType;
}
#endregion
/// <summary>
/// Set the presenter by injection.
/// </summary>
[InjectionMethod]
public void InjectPresenter([CreateNew]DevExGridViewPresenter<IBindingView> pPresenter) {
SetPresenter(pPresenter);
}
}
}
My foundation:
viewFactory.UnregisterViewType(ViewNames.BasicGrid); viewFactory.RegisterViewType<Views.GreyGridView>(ViewNames.BasicGrid);
Edited by orcities - 02-Jan-2008 at 12:54pm
|
 |