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: 10-Jan-2008 at 1:17pm
Delight,
Great example.  It is going to take me some time to go through it but I will probably have questions.
Back to Top
DeLight View Drop Down
Newbie
Newbie


Joined: 23-Aug-2007
Location: Belarus
Posts: 15
Post Options Post Options   Quote DeLight Quote  Post ReplyReply Direct Link To This Post Posted: 10-Jan-2008 at 1:53am
well.. sorry, have no time to write much. worked on detail grid problem long time ago. solved it with custom DevExGridViewAdapter and GridViewContext.
 
files:
 
hope you find the way to use the sources. any questions are welcome.
 
example:
private void AddBedGridView()
{
EntityBindingSource ebs = new EntityBindingSource(typeof(Room), EntityManager, ParentRootEntity, ClientGroup.Descriptors.RoomList.PropertyPath);

GridViewContext gvc = GridViewContext.AddNew(WorkItem, PlaceholderNames.SettleFreeBeds, ebs);

gvc.DefaultGridBuilderPrototypeName = GridBuilderNames.SettleRooms;

gvc.RowClickHandler = PlaceChosen;

gvc.AutoExpandAllMasterRows = true;

DetailGridViewContext dgvc = new DetailGridViewContext(gvc, "Beds", typeof(Bed), Room.Descriptors.FreeBeds);

dgvc.RowClickHandler = PlaceChosen;

dgvc.DefaultGridBuilderPrototypeName = GridBuilderNames.SmallSettleRoomsBedsDetail;

AddNewSubGridView<Room>(PlaceholderNames.SettleFreeBeds);

}

...

private void PlaceChosen(GridRowEventArgs e)

{

if (e.RowObject is Room)

{ ... }

else if (e.RowObject is Bed)

{ ... }

}

 


Edited by DeLight - 10-Jan-2008 at 2:17am
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: 08-Jan-2008 at 11:28am
I agree it is not the right way to do it. But, this problem put me almost a month behind. I will refactor later if I get more information.
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: 08-Jan-2008 at 11:25am

Well, it pretty much blows view encapsulation and isolation out of the water, but I'm glad you're moving again.

I too am bewildered by the fact that your CurrencyManager was null, but I've gotten busy again and don't have time to look at it.  When things calm down, I'll try it on my test project.
 
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: 08-Jan-2008 at 7:06am
I have made the DetailGridView visible from my Context. This allows me to create any event that I want. Using the grid events I can get the data row information.
 
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: 07-Jan-2008 at 9:57am
This is proving to be very difficult. I can access the new DetailGridViewContext and the DetailGridBindingManager.
 
But, the problem is that the DetailGridBindingManager.CurrencyManager is alway empty.
 
I have set my DetailGridBindingManager in my DetailGridViewBuilder.CreateDetailGrid(). In the page controller I add the MyDetailGridViewContext to the GridViewContext. Then when the position for the GridViewContext.BindingSource.PositionChanged is fired I create an event that catches when the DetailGridViewContext position has changed.
 
This works but then the DetailGridBindingManager.CurrencyManager is empty.
 
Puzzling
 
 
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 5:00pm
Actually, I've been waiting to see what you'd do with this once we got it working.
 
You must create the DetailGridViewContext and add it to the main GridViewContext in your PageController.  You'll need to keep a reference to it around in a member variable somewhere.
 
Then, whenever a detail grid view is open, its BindingManager will be available in the DetailGridViewContext.
 
I'm not sure how you plan to make use of this information.
 
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 3:08pm
Ok, now that I have it running my grid builder and saving my detailgridviewcontext with the gridbindingmanager visible I need to figure out how to get to it and find the current item.
 
I am not sure how that would be done.  I can't do it in the PageController.Add...DetailGrid because it hasn't called CreateDetailGrid() to set the Context.DetailGridBindingManager.
 
Do you have a suggestion, theory, etc. on way to proceed?
 
 
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
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 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 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: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: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 11:55am
Thank you for your help. Just knowing your helping is nice. I will try that and see what happens.
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
 Post Reply Post Reply Page  <1234>

Forum Jump Forum Permissions View Drop Down