Is this correct?
Below is the process I used to create a new base view and add views/controls to that view.
Goal View: Has Three SmartPartPlaceholders on it.
TopPlaceHolder -> will hold grid view
MiddlePlaceHolder -> will hold action buttons
BottomPlaceHolder -> will hold current values
1. Create View Class and add to <Business>.<App>.Foundation.Views
ThreePaneView.cs
2. Add SmartPartPlaceholders
3. In View Constructor add method call: SetSmartPartPlaceHolderNames();
4. Build SetSmartPartPlaceHolderNames(); method:
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;
}
5. Add reference to Placeholders in <Business>.<App>.Interface.Constants.Workspaces
6.
public const string AvailableSmartPartPlaceholder = "AvailableSmartPartPlaceholder";
public const string AssignedSmartPartPlaceholder = "AssignedSmartPartPlaceholder";
public const string ActionSmartPartPlaceholder = "ActionSmartPartPlaceholder";
7. Create Grid View to place in "AssignedSmartPartPlaceholder";
8. Create UserRolesGridView displays Roles that are assigned to User in the UserRoles Entity.
9. Create TabController - ManageUserRolesTabControl
10. Add/Modify CreateView() method to get data and show control
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;
//CreateView<UserRolesGridView>(); //Just adds the grid to page
UserRolesGridView
mAssignedView = WorkItem.SmartParts.AddNew<UserRolesGridView>();
AssignedWorkspace.Show(mAssignedView);
}
11. Get the ThreePanelView Control's SmartPart Placeholder
private IWorkspace ActionWorkspace{
get{ return WorkItem.Workspaces[WorkspaceNames.ActionSmartPartPlaceholder];
}
}
I either run into a problem with binding.
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].
Or if I try to add a control with user type just to see if it works I get:
Value cannot be null.
Parameter name: id
In the GridViewPresenterBase class. Funny thing is I am not trying to bind any grid.
Altered CreateView() as such. ActionButtonView just has 2 buttons on it. And to get it to run to this point I changed the boundtype to be User.
public
override void CreateView(){
ActionButtonsView
mActionButtonView = WorkItem.SmartParts.AddNew<ActionButtonsView>();ActionWorkspace.Show(mActionButtonView);
}
Edited by orcities - 20-Sep-2007 at 11:04am