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 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?
|
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
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.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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.
|
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
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.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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.
|
|
DeLight
Newbie
Joined: 23-Aug-2007
Location: Belarus
Posts: 15
|
Post Options
Quote Reply
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
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 10-Jan-2008 at 2:13pm |
Where are you tying the GRidView.RowClick to the Context.RowClick Event?
|
|
DeLight
Newbie
Joined: 23-Aug-2007
Location: Belarus
Posts: 15
|
Post Options
Quote Reply
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
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
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.
|
|
DeLight
Newbie
Joined: 23-Aug-2007
Location: Belarus
Posts: 15
|
Post Options
Quote Reply
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.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 11-Jan-2008 at 11:30am |
Where do you have DevExGridViewMenuItem ?
|
|
DeLight
Newbie
Joined: 23-Aug-2007
Location: Belarus
Posts: 15
|
Post Options
Quote Reply
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.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 11-Jan-2008 at 12:15pm |
It is actually not defined in any of those files. I have tried searching all the documents.
|
|