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: 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
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: 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
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
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 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
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: 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
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: 10-Jan-2008 at 2:13pm
Where are you tying the GRidView.RowClick to the Context.RowClick Event?
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 4:02pm
some other files you need:
 
Originally posted by orcities

Where are you tying the GRidView.RowClick to the Context.RowClick Event?
 
DeExGridViewAdapter:
public override void InitializeGridViewEvents()
{
...
GridView.MouseDown += MouseDownHandler;
...
}
 
void MouseDownHandler(object sender, MouseEventArgs e)
{
GridView gv = (GridView) sender;
GridHitInfo hitInfo = gv.CalcHitInfo(e.X, e.Y);
if (hitInfo.IsValid && hitInfo.InRow && gv.IsDataRow(hitInfo.RowHandle))
{
object rowObject = gv.GetRow(hitInfo.RowHandle);
if (rowObject == null)
    return;
 
GridRowEventArgs info = new GridRowEventArgs(rowObject);
ViewContext.OnRowClick(info);
}
 
mLastHitInfo = hitInfo;
}
 
 
 


Edited by DeLight - 10-Jan-2008 at 4:11pm
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: 11-Jan-2008 at 7:20am
I really like everything you have done. I will probably end up adding Drag-n-Drop to the features eventually.
 
Could I also get the code for the DevExGridViewMenuItem
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: 11-Jan-2008 at 8:03am

An example of the Context Menu use would be great to. I am tempted to ask for you whole cabana changes. I really like what you have done.

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: 11-Jan-2008 at 11:08am

example of using context menus (almost the same way as using RowClick events):

context.GridViewContextMenuVisible = true;

context.AddContextMenuItem("Add item", MakeWorkItemSpecificId(CommandNames.AddNew));

context.AddContextMenuItem("Edit item", EditReservationHandler);

context.AddContextMenuItem("Delete parent item (no action)", true);

context.AddChildContextMenuItem("Delete option 1", DeleteReservationHandler);

context.AddChildContextMenuItem("Delete option 2", AnnulReservationHandler);

...
 

private void EditReservationHandler(GridRowEventArgs e)

{

EditorService.Edit(EditorNames.Reservation, (Reservation) e.RowObject);

}

...
 
CabFns.RegisterLocalCommandHandler(WorkItem, this.MakeWorkItemSpecificId(CommandNames.AddNew), AddReservation);
 

protected override void AddReservation(object sender, EventArgs e)

{

EditorService.AddNew(EditorNames.Reservation, null);

}

notice that menu items for adding objects are added via command names, so this menuitems are shown even when no data is present in grid.
 
ps. compiling all my changes to original Cabana in one solution (in one framework) is my big plan for nearest future after my main project big release (last days of January). and I wonder if IdeaBlade is going to release new version of Cabana - maybe we have to cooperate some way.
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: 11-Jan-2008 at 11:30am

Where do you have DevExGridViewMenuItem ?

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: 11-Jan-2008 at 12:09pm
Originally posted by orcities

Where do you have DevExGridViewMenuItem ?
DevExGridViewMenuItem is DXMenuItem with some additional properties (current RowObject to refer to it in MenuItem click handler and SourceContextMenuItem to fire the handler in controller). It is used only in IdeaBlade.Cab.DevEx project. It is included in DetailGrid2.rar which I've uploaded recently.
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: 11-Jan-2008 at 12:15pm
It is actually not defined in any of those files. I have tried searching all the documents.
Back to Top
 Post Reply Post Reply Page  <1234>

Forum Jump Forum Permissions View Drop Down