New Posts New Posts RSS Feed: [Resolved]Accessing current DetailGrid object???????
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[Resolved]Accessing current DetailGrid object???????

 Post Reply Post Reply Page  <1234>
Author
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Topic: [Resolved]Accessing current DetailGrid object???????
    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.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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));
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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);
        }
 

 
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 11:50am
Wow! 
 
It's only January 4th and we already have a nominee for the Most Obscure Cabana Code award of 2008!
 
I built a grid view similar to yours (using our newer Cabana version) and it fails in exactly the same way.  Here's how to fix it:
 
Make a generic version of GreyGridView (that merely passes the compile-time type parameter to the constructor at runtime) in GreyGridView.generic.cs:
 

namespace (yournamespace) {

// Can't put this inside GreyGridView.cs because VS Designer fails on a generic class.

[SmartPart]

public class GreyGridView<TBoundType> : GreyGridView {

/// <summary>Ctor.</summary>

public GreyGridView() : base(typeof(TBoundType)) { }

}

}

Then register THAT instead of the non-generic version using this overload:

viewFactory.RegisterViewTypeLOC.CEMS.Interface.Constants.ViewNames.GreyGridView, typeof(GreyGridView<>));

(Note the "<>" on the second parameter.)
 
That's exactly what Cabana does with the DevExBasicGridView and should get you past the abstract class problem.
 
I still don't fully understand why the non-generic version doesn't work right--it fails pretty deep in the object builder strategy chain, but there may be some assumption in the view factory that I don't know about.  I'll try to get Ward's attention and ask him about it.
 
Hope this gets you moving.  Sorry to take so long to figure it out.
 
Bill J. 
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 11:55am
Thank you for your help. Just knowing your helping is nice. I will try that and see what happens.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 12:30pm
Error 43 The non-generic method 'IdeaBlade.Cab.UI.Services.ViewFactoryServiceBase.RegisterViewType(string, System.Type)' cannot be used with type arguments C:\Development\CEMS\Source\Foundation\Services\ViewFactoryService.cs 25 7 LOC.CEMS.Foundation
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 12:32pm
Once again version differences cause a problem.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 12:41pm
It is strange I see it the correct RegisterViewType(string, type) but I it doesn't show in the compiled version.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 12:45pm
My fault again. I was still doing RegisterViewType<>(). Got it to work.
Tx
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 2:05pm
Next problem. It is not using anything that I have set. Meaning it is not using the presenter. I have set a break point in the LOCGridViewPresenter.AddDetalGrid and is never hit.
 
Presenter:

public class LOCGridViewPresenter<TView> : DevExGridViewPresenter<TView> where TView : IBindingView

{

        protected override void AddDetailGrid(DetailGridViewContextBase DetailViewContext)

        {

            DetailGridViewBuilderBase detailGridBuilder = new LOCDetailGridViewBuilder(DetailViewContext, BindingManager);

            detailGridBuilder.Build();

        }

}

 
GreyGridView:

[InjectionMethod]

public void InjectPresenter([CreateNew]LOCGridViewPresenter<IBindingView> pPresenter) {

     SetPresenter(pPresenter);

}

 

PageController:

CreateChildGridContext();

pContext.ChildViewId = ChildViewId;
ViewFactory.AddNew(Constants.ViewNames.GreyGridView, WorkItem, ChildViewId, typeof(QuestionGroup));

 

private void CreateOrganizationGridContext()

{

            AssignmentBindingSource = new EntityBindingSource(typeof(Organization), EntityManager, mEmptyOrgList, String.Empty);

            GridViewContext context = GridViewContext.AddNew(WorkItem, Constants.WorkspaceNames.SearchResultsViewSmartPartPlaceholder, AssignmentBindingSource);

            IGridBuilderService gridBuilderService = this.WorkItem.Services.Get<IGridBuilderService>();

            context.GridBuilderPrototype = gridBuilderService.Get<Organization>();

 

            AddAssignmentDetailGrid(context);

}

 

private void AddAssignmentDetailGrid(GridViewContext pParentViewContext)

{

  // Create the view context for the detail view

  DetailGridViewContextBase mDetailViewContext = new LOCDetailGridViewContext(pParentViewContext, "Contact", typeof(OrganizationContact),

 EntityRelations.Organization_OrganizationContact.ChildRelationPropertyName);

}

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Jan-2008 at 2:14pm
I had the Generic inheriting the wrong class. My bad.
Back to Top
 Post Reply Post Reply Page  <1234>

Forum Jump Forum Permissions View Drop Down