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  123 4>
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: 14-Dec-2007 at 9:58am
If you have a grid and you want to add a nested grid in it (DetailGrid) you add the DetailGridViewContext to the current GridViewContext.
 
I am trying to figure out how to get the currently selected item from that DetailGrid. I can get the current parent Item using the BindingSource.Current. But I have been unsuccessful in getting the Child items current.
 
Anyone have a clue.
 
Bill????


Edited by orcities - 11-Feb-2008 at 1:09pm
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: 19-Dec-2007 at 9:13am
What I have found is that if I try and use the detailViewContext.BindingSource it reverts to the BindingSource of the Root grid.
 
Any help would be great.
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: 19-Dec-2007 at 3:19pm
Bill please confirm something for me.
 
If I want to add drag and drop or any other functionality to the DataGridView I will need to do the following:
 
Create:
 I[x]GridViewPresenter
 [x]GridViewPresenter : I[x]GridViewPresenter
        in the AddDetailGrid callthe appropriate GridViewBuilder that implements my events
 [x]GridViewAdapter that calls the approprate [x]GridViewContextBase that sets the event handler
 
Then in the View call the appropriate [x]GridViewPresenter class.
 
I haven't been able to find where it builds the root Grid.
 
Is this close to correct.
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: 21-Dec-2007 at 2:26pm
Two questions in this thread.
 
Regarding the first:
 
As you can see in GridViewPresenter.cs (in IdeaBlade.Cab.UI), the detail grid(s) is (are) created by invoking the DevExDetailGridViewBuilder (set by the view at presenter injection time because it's dependent on the particular view technology--DevEx in this case).
 
The DevExDetailGridViewBuilder (in IdeaBlade.Cab.DevEx) actually creates the grid, creating a detail grid binding manager and binding it to a Relation property of the master object.
 
Unfortunately, getting at the detail grid binding manager and its data source is tough since they are not exposed to the presenter.  You can inherit from DevExDetailGridViewBuilder and override CreateDetailGrid().  Call the base method, then, before returning, set the detail binding manager into the DetailGridViewContext (you'll need your own derived detail context class to have a place to put it).
 
The next problem is that the type of the detail grid builder is hard-coded into the DevExGridView rather than being taken from the GridBuilderService.
 
You might be able to inherit from DevExBasicGridView and override the InjectPresenter() method.  Call SetPresenter(), then call
 
pPresenter.SetDetailGridViewBuilder(new MYDetailGridViewBuilder(GridBindingManager));
 
to substitute your detail grid view builder for the standard one.
 
I haven't tried this, so there might be some gotchas I've missed.  You'll have to make the call as to whether its worth it.
 
Regarding, the second question, yes you're on the right track.  By overriding DevExBasicGridView you can inject your custom presenter type.
 
The master grid is created by GridViewPresenter when the ViewContext has been set.
 
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: 28-Dec-2007 at 10:09am
DataGridView does not implement InjectPresenter and the Presenter does not have the SetDetailGridViewBuilder Class
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: 28-Dec-2007 at 5:06pm
Look at DevExBasicGridView (in IdeaBlade.Cab.DevEx).
 
You'll need to create your own MYDevExBasicGridView inheriting from DevExBasicGridView, define a public InjectPresenter() method [with the "new" modifier], and register it with the ViewFactoryService in place of the standard DevExBasicGridView.
 
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: 02-Jan-2008 at 7:19am
So I also need to create my own presenter? And My own SetDetailGridViewBuilder method?
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: 02-Jan-2008 at 9:28am
When I do that I get the following error. And I can't track where it is being thrown from.
 
 
"Could not find an appropriately matching constructor."
 
All i have done so far is Inherit from the DevExBasicGridView and add Register it.


Edited by orcities - 02-Jan-2008 at 1:13pm
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: 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
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: 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.
 
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: 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);

    }

  }

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: 02-Jan-2008 at 2:04pm
5. pPresenter.SetDetailGridViewBuilder() doesn't exist.
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: 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.
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: 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.
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: 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)

 
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: 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.
Back to Top
 Post Reply Post Reply Page  123 4>

Forum Jump Forum Permissions View Drop Down