Custom Module: are multiple backend views possible?
I have a custom module that was created from code rather than by use of the Module builder. The module is used to create School Calendar Day Items that identify "out of session" dates and reasons (Holidays, Vacation, Staff Development Days, etc.)
Each "SchoolCalendarDay" has a "SchoolYearCalendar" and a "SchoolCalendarDayType" associated with it. My table mappings are setup and working properly and look like this.
MappingConfiguration<SchoolYearCalendar> schoolYearCalendarTableMapping =
new
MappingConfiguration<SchoolYearCalendar>();
schoolYearCalendarTableMapping.MapType().ToTable(
"sf_nlg_school_year_calendar"
);
schoolYearCalendarTableMapping.HasProperty(y => y.Id).IsIdentity(Telerik.OpenAccess.Metadata.KeyGenerator.Guid);
schoolYearCalendarTableMapping.HasProperty(y => y.StartDate).IsNotNullable();
schoolYearCalendarTableMapping.HasProperty(y => y.EndDate).IsNotNullable();
schoolYearCalendarTableMapping.HasProperty(y => y.CreatedBy).IsNotNullable();
schoolYearCalendarTableMapping.HasProperty(y => y.CreateDate).IsNotNullable();
MappingConfiguration<SchoolCalendarDay> calendarDayTableMapping =
new
MappingConfiguration<SchoolCalendarDay>();
calendarDayTableMapping.MapType().ToTable(
"sf_nlg_school_year_calendar_day"
);
calendarDayTableMapping.HasProperty(d => d.Id).IsIdentity(Telerik.OpenAccess.Metadata.KeyGenerator.Guid);
calendarDayTableMapping.HasProperty(d => d.SchoolYearCalendarId).IsNotNullable();
calendarDayTableMapping.HasProperty(d => d.Date).IsNotNullable();
calendarDayTableMapping.HasProperty(d => d.CreatedBy).IsNotNullable();
calendarDayTableMapping.HasProperty(d => d.CreateDate).IsNotNullable();
calendarDayTableMapping.HasProperty(d => d.SchoolDayTypeId).IsNotNullable();
calendarDayTableMapping.HasProperty(d => d.AdditionalInfo);
MappingConfiguration<SchoolCalendarDayType> calendarDayTypeTableMapping =
new
MappingConfiguration<SchoolCalendarDayType>();
calendarDayTypeTableMapping.MapType().ToTable(
"sf_nlg_school_year_calendar_day_type"
);
calendarDayTypeTableMapping.HasProperty(t => t.Id).IsIdentity(Telerik.OpenAccess.Metadata.KeyGenerator.Autoinc);
calendarDayTypeTableMapping.HasProperty(t => t.Description).IsNotNullable();
calendarDayTypeTableMapping.HasProperty(t => t.SortOrder).IsNotNullable();
calendarDayTableMapping.HasAssociation(d => d.DayType).ToColumn(
"school_day_type_id"
);
calendarDayTableMapping.HasAssociation(d => d.SchoolCalendar).ToColumn(
"school_year_calendar_id"
);
List<MappingConfiguration> mappings =
new
List<MappingConfiguration>();
mappings.Add(calendarDayTypeTableMapping);
mappings.Add(schoolYearCalendarTableMapping);
mappings.Add(calendarDayTableMapping);
I created a "SchoolCalendarAdminView" and "AddEditSchoolCalendarView" controls so I can add and edit new SchoolCalendarDay items. While everything works properly, I also need a way to add/edit "SchoolYearCalendar" and "SchoolCalendarDayType" items.
Is it possible for a module to have multiple backend views or do I need to create seperate SchoolYearCalendar and SchoolCalendarDayType modules?
--Steve
Hi Steve,
Yes, a single module can have different Backend pages associated with it and each page would invoke different create/edit views - it's just a matter of definitions. For example the Locations module from the SDK has the following definition:
var locationsGridView =
new
MasterGridViewElement(backendContentView.ViewsConfig)
ViewName = LocationsDefinitions.BackendListViewName,
ViewType =
typeof
(MasterGridView),
AllowPaging =
true
,
DisplayMode = FieldDisplayMode.Read,
ItemsPerPage = 50,
SearchFields =
"Title"
,
SortExpression =
"Title ASC"
,
Title =
"Locations"
,
WebServiceBaseUrl =
"~/Sitefinity/Services/Content/Locations.svc/"
;
backendContentView.ViewsConfig.Add(locationsGridView);
Hi Lubomir,
Thanks for the info.
Steve