Print Page | Close Window

[Solved]Adding Grids to View

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=436
Printed Date: 11-Jun-2026 at 6:01pm


Topic: [Solved]Adding Grids to View
Posted By: orcities
Subject: [Solved]Adding Grids to View
Date 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?




Replies:
Posted By: Bill Jensen
Date 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.
 


Posted By: orcities
Date 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.


Posted By: orcities
Date Posted: 19-Sep-2007 at 7:55am
I have placed that View in the Foundation.Views Folder of my project.


Posted By: orcities
Date 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;

 


Posted By: orcities
Date 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.
 
 


Posted By: Bill Jensen
Date 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.


Posted By: orcities
Date 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.
 
 


Posted By: Bill Jensen
Date 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.


Posted By: orcities
Date 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>());

}



Posted By: orcities
Date 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>();


Posted By: orcities
Date 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);



Posted By: orcities
Date Posted: 21-Sep-2007 at 9:36am
See http://www.ideablade.com/forum/forum_posts.asp?TID=443 - Process for creating new Base View?



Print Page | Close Window