New Posts New Posts RSS Feed: [Solved]Adding Grids to View
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[Solved]Adding Grids to View

 Post Reply Post Reply
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: [Solved]Adding Grids to View
    Posted: 18-Sep-2007 at 3:28pm

How do I go about adding a Grid to a View.

I have a view with a SmartPartPlaceHolder docked at the top and bottom with buttons in a panel in the center.

How do I add a grid to the place holder?
How do I hook up the buttons?



Edited by orcities - 21-Sep-2007 at 9:34am
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: 18-Sep-2007 at 5:27pm
While you can certainly proceed in the way you suggest, we'd advise a somewhat different approach.  Rather than mixing controls and other views in a single view, Cabana emphasizes separation between "layout" views that only contain other views and defined the "floor" plan of the UI, and "widget" views that contain only controls that bind to data.
 
If the layout views supplied with Cabana don't meet your needs, you can create your own, using the Cabana examples as a model.  A layout view typically comes with a view or page controller that can be subclassed for different purposes.   Often you override methods such as "CreateView()" or "CreateSummaryView()" to supply the views to be displayed in various parts of the layout.
 
Moreover, grids and loose controls have different data binding requirements, so we recommend separating them into separate views.
 
For control views containing action buttons (or which require actions on other events), you can create a custom presenter and inject it into the view.  The view fields events from controls but performs little or no processing, instead invoking methods on the presenter.  If the presenter must control or transfer information to the view, you have a couple of options:
 
1.  You can provide a custom interface to the view (extending IBindingView) that the presenter knows about. 
 
2.  A better mechanism that reduces the presenter's dependence on the view is to let the view register one or more delegates with the presenter to be called to invoke functions or set values in the view.  This way, the interface is actually defined by the presenter, and it could actually serve multiple views.
 
Hope this answers some of your questions.
 
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: 19-Sep-2007 at 7:55am
I have made a view with three smartpartplaceholder controls. Now how do I add other views to it?
 
The presenter for the ControlViewPresenter doesn't have a CreateView method to override.
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-Sep-2007 at 7:55am
I have placed that View in the Foundation.Views Folder of my project.

Edited by orcities - 19-Sep-2007 at 7:55am
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-Sep-2007 at 11:22am
I tried to add one of my gridviews to the new three panel view. Using the same tech. as the Spash module. By placing code in the module controller.
 
This did not work. I can't figure out how to add any other views/grids to my new view.
 
private void ShowUserSummaryPagePageHandler(Object sender, EventArgs e)
{
UserSummaryPageController.ShowPage(WorkItem, ViewNames.UserSummaryPage, this.Workspace);

AvailableWorkspace.Show(mAssignedRoles);

private void AddViews(){mAssignedRoles = WorkItem.SmartParts.AddNew<UserRolesGridView>();}

private IWorkspace AvailableWorkspace{

get { return WorkItem.Workspaces[WorkspaceNames.AvailableWorkspace]; }

}

private UserRolesGridView mAssignedRoles;

 
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-Sep-2007 at 11:36am
I also tried putting it in the tab controller but it gives me an error saying the types don't match. The page type is User the tab is UserRole. It is saying :
{"The item type of the BindingSource that you selected [LOC.CEMS.Model.User] does not match  the BoundType of this BindingManager [LOC.CEMS.Model.Role]."}
 
I am only trying to load an existing grid into one of the smartpart placeholders on the view. I have another tab with the same grid that is loading fine.
 
 
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: 19-Sep-2007 at 11:53am

Is your "UserSummaryPage" the page that will contain the three SmartPartPlaceHolders? 

If so, then shouldn't the code to populate them be in the UserSummaryPageController?
 
What does UserSummaryPageController inherit from?
 
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: 19-Sep-2007 at 12:42pm
The UserSummaryPage is the base page. I am trying to add the view with the 3 place holders to a tab (ManageUserRolesTabController).
 
The 3 place holders control is called ManageUserRolesView.
 
I have tried adding the code to populate the three place holders in the ManageUserRolesTabController that the view is on.
 
I get that the types do not match.
 
 
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: 19-Sep-2007 at 1:07pm

In your tab view controller, you should create a GridViewContext for each detail view and add it to the workitem (see MasterDetailTabViewController.cs in IdeaBlade.Cab.UI for an example). 

In the GridViewContext you pass the binding source for the Grid.   For the example you mentioned, this should be an EntityList of Role objects.
 
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: 19-Sep-2007 at 1:17pm
This is what I have. It comes back saying :

The item type of the BindingSource that you selected [LOC.CEMS.Model.User] does not match the BoundType of this BindingManager [LOC.CEMS.Model.Role].

 
public override void CreateView()

{

mBindingSource =

new EntityBindingSource(typeof(Role), EntityManager, mEmptyList, String.Empty);

ViewId = "UserRolesGridView";

//Choose DetailRoleGrid

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

GridBuilderBase pGridBulderProtoType = pGridBuilderService.Get("DetailRole");

GridViewContext detailRoles = GridViewContext.AddNew(WorkItem, ViewId, mBindingSource);

detailRoles.GridBuilderPrototype = pGridBulderProtoType;

WorkItem.Workspaces[WorkspaceNames.AssignedWorkspace].Show(WorkItem.SmartParts.AddNew<UserRolesGridView>());

}

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-Sep-2007 at 1:54pm
I am using the exact same code for my gridview tab controller and it loads just fine. The only difference is I do not work with w/ the workitem.
 
I use CreateView<UserRolesGridView>();
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: 20-Sep-2007 at 9:23am
If I try to add the ActionsControl, which just contains 2 buttons, it fails. It acts as if the it does know the areas in the View exist, ActionWorkspace == null.
 
In the Foundation.ThreePanelView I have the following:

private void SetSmartPartPlaceHolderNames() {

// Critical! Must set SmartPartPlaceHolder name immediately or mysterious exception during create.

mAvailableSmartPartPlaceholder.SmartPartName = WorkspaceNames.AvailableSmartPartPlaceholder;

mActionSmartPartPlaceHolder.SmartPartName = WorkspaceNames.ActionSmartPartPlaceholder;

mAvailableSmartPartPlaceholder.SmartPartName = WorkspaceNames.AssignedSmartPartPlaceholder;

}

In the tab controller I am trying to add the control to the Workspace.ActionSmartPartPlaceholder

private IWorkspace ActionWorkspace

{

get { return WorkItem.Workspaces[WorkspaceNames.ActionSmartPartPlaceholder]; }

}

public override void CreateView()

{ ...(snip)...

ActionButtonsView
mActionButtonView = WorkItem.SmartParts.AddNew<ActionButtonsView>();

ActionWorkspace.Show(mActionButtonView);

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: 21-Sep-2007 at 9:36am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down