Здравствуйте!
Добавляю в окно дополнительное поле в данном случае "Подвал" и хочу сделать возможность выбора его значения, как занести эти данные в справочник(необходимо заполнить поле LookupDatasetLink), чтобы корректно отображались необходимые данные.
Нравится
Нужно на карточке создать невизуальный компонент типа DataLink, привязать его к датесету справочника «Подвалы», а затем у копонента edtPodval сослаться на этот DataLink в поле LookupDatasetLink.
Есть статья Создание нового справочника или см. в руководстве администратора.
А как Вы собрались фильтровать, в саму карточку помещения ещё не добавили поле?
Спасибо за наводку, справочник создал , в карточку поле добавил
но вот когда добавляю новую квартиру указав в поле подвал то, или иное значение, после добавления и повторного просмотра карточки поле остается пустым и фильтрации не происходит, если я ее делаю только по полю подвал
мои действия сейчас, мне необходимо добавить в wnd_ObjectsWorkspaceScript кусок скрипта для выполнения тех или иных действий при выборе значения из поля "подвал"? и почему не сохраняется значение при добавлении новой карточки?
В карточку поле добавляется не так.
См. статью как добавить вручную или воспользуйтесь FieldMaker.
Добавил через FieldMaker, все ок,
добавляю в левое поле, где фильтрация и пытаюсь отфильтровать только по нему, фильтрация не происходит...
Или туда тоже надо через FieldMaker добавлять?
Судя по скриншоту, левая панель — это не базовая логика, а какие-то доработки.
Нужно сделать полностью аналогично какому-то другому полю-справочнику этой панели.
сделал аналог по ЖК сразу же, может нужно дорабатывать скрипт запроса в базу данных, по выбору значения из этого поля?
Вот сам скрипт по обработке запросов из этого окна wnd_ObjectsWorkspace, сюда не надо ничего добавлять?:
// ---------------------------------------------------------------------------- // wnd_ObjectsWorkspaceScript // ---------------------------------------------------------------------------- var ObjectsWorkspace = new Object(); function Initialize() { InitializeGroups('tbl_ObjectsGroup', 'ds_ObjectsInGroup', 'ObjectsID'); InitializeGridData(); pgGraphs.IsVisible = false; pgGraphs.IsAccessible = false; pgGraphsDetail.IsVisible = false; pgGraphsDetail.IsAccessible = false; } function InitializeGridData() { var GridWindow = wndGridData.Window; PrepareGridWindow(GridWindow, dlObjects); wndCheckerboard.Window.Prepare(); wndCheckerboard.Window('dlData').Dataset.Open(); dlCheckerboard.Dataset = wndCheckerboard.Window('dlData').Dataset; PrepareCommonDetails('ObjectsID'); PrepareChangeLogContract('ContractID'); } function InitializeCheckerboard(BuildingID, SectionID, GroupID, IsExtended) { var grdData = wndCheckerboard.Window('grdData'); wndCheckerboard.Window.BeginUpdate(); grdData.IsMultiLineData = false; var DatasetLink = wndCheckerboard.Window('dlData'); var Dataset = DatasetLink.Dataset; Dataset.Close(); grdData.DatasetLink = System.EmptyValue; PrepareCheckerboard(Dataset, SectionID, GroupID, BuildingID, IsExtended); grdData.DatasetLink = DatasetLink; grdData.IsMultiLineData = true; wndCheckerboard.Window.EndUpdate(); } function RefreshObjects() { RefreshWorkspace(); } function InitializeObjectsGroupsDetail() { ObjectsWorkspace.ObjectsGroupsWindow = wndGroupsDetail.Window; SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'DatasetUSI', 'ds_ObjectsInGroup'); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'SelectDataTableUSI', 'tbl_ObjectsGroup'); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'ParentItemFieldName', 'ObjectsID'); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'ItemTypeName', "Объекты"); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'MemoryDatasetUSI', 'mds_GroupsDetail'); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'WorkspaceGridDataset', BaseWorkspace.GridDataset); ObjectsWorkspace.ObjectsGroupsWindow.Prepare(); var DatasetLink = ObjectsWorkspace. ObjectsGroupsWindow.ComponentsByName('dlData'); ObjectsWorkspace.ObjectsGroupsDataset = DatasetLink.Dataset; } function RefreshObjectsGroupsDetail() { if (ObjectsWorkspace.InitializeObjectsGroupsFlag != true) { InitializeObjectsGroupsDetail(); ObjectsWorkspace.InitializeObjectsGroupsFlag = true; } var ObjectsID = dlObjects.Dataset.ValAsGUID('ID'); SetAttribute(ObjectsWorkspace.ObjectsGroupsWindow, 'ParentItemID', ObjectsID); RefreshDataset(ObjectsWorkspace.ObjectsGroupsDataset); } //%Init and Refresh Detail Functions% (Workspace Wizard Bookmark) function RefreshDetails(ParentItemID) { if (!scr_BaseWorkspace.RefreshDetails()) { return; } if (pcDetails.ActivePage.Name == pgGroupsDetail.Name) { RefreshObjectsGroupsDetail(); } else if (pcDetails.ActivePage.Name == pgAccessDetail.Name) { RefreshAccessDetail(BaseWorkspace, wndAccessDetail, 'tbl_ObjectsRight'); } /*else if (pcDetails.ActivePage.Name == pgReservationDetail.Name) { RefreshCommonDetail(BaseWorkspace, wndReservationDetail, 'ObjectsID', 'ObjectsID', null, null, null, null, null, ParentItemID); }*/ else if (pcDetails.ActivePage.Name == pgObjectHistoryDetail.Name) { RefreshCommonDetail(BaseWorkspace, wndObjectHistoryDetail, 'ObjectsID', 'ObjectsID', null, null, null, null, null, ParentItemID); } else if (pcDetails.ActivePage.Name == pgTasksDetail.Name) { RefreshCommonDetail(BaseWorkspace, wndTasksDetail, 'ObjectID', 'ObjectID', null, null, null, null, null, ParentItemID); } else if (pcDetails.ActivePage.Name == pgContractDetail.Name) { RefreshCommonDetail(BaseWorkspace, wndContractDetail, 'ObjectID', 'ObjectID', null, null, null, null, null, ParentItemID); } else if (pcDetails.ActivePage.Name == pgDocumentDetail.Name) { SetAttribute(wndDocumentDetail.Window, 'HideButtonsFrame', true); RefreshCommonDetail(BaseWorkspace, wndDocumentDetail, 'ObjectID', 'ObjectID', null, null, null, null, null, ParentItemID); } else if (pcDetails.ActivePage.Name == pgPriceHistoryDetail.Name) { SetAttribute(wndPriceHistoryDetail.Window, 'HideButtonsFrame', true); RefreshCommonDetail(BaseWorkspace, wndPriceHistoryDetail, 'ObjectsID', 'ObjectsID', null, null, null, null, null, ParentItemID); } else if (pcDetails.ActivePage.Name == pgFilesDetail.Name) { RefreshFilesDetail(BaseWorkspace, wndFilesDetail, 'ObjectID', 'tbl_FileInObject', 'iq_FileInObject', "объекта", ParentItemID); } else if (pcDetails.ActivePage.Name == pgDeficit.Name) { RefreshCommonDetail(BaseWorkspace, wndDeficit, 'ObjectID', 'ObjectID', null, 'wnd_DeficitEdit'); } else if (pcDetails.ActivePage.Name == pgInvoiceDetail.Name) { RefreshCommonDetail(BaseWorkspace, wndInvoiceDetail, 'ObjectID', 'ObjectID'); } else if (pcDetails.ActivePage.Name == pgLayout.Name) { RefreshLayoutDetail(); } else if (pcDetails.ActivePage.Name == pgObjectLogPrice.Name) { SetAttribute(wndObjectLogPrice.Window, 'HideButtonsFrame', true); RefreshCommonDetail(BaseWorkspace, wndObjectLogPrice, 'ObjectID', 'ObjectID'); } //%Refresh Details BookMark% (Workspace Wizard Bookmark) else if (pcDetails.ActivePage.Name == pgHistoryUDDU.Name) { RefreshCommonDetail('', wndHistoryUDDU, 'BuildingID', 'BuildingID', 'ds_DatePlanCompletedUDDULog', 'wnd_BuildingEdit', null, true, false, GetFieldValueFromDisabledField(BaseWorkspace.GridDataset, 'BuildingID')); } else if (pcDetails.ActivePage.Name == pgHistoryPDKP.Name) { RefreshCommonDetail('', wndHistoryPDKP, 'BuildingID', 'BuildingID', 'ds_DatePlanCompletedPDKPLog', 'wnd_BuildingEdit', null, true, false, GetFieldValueFromDisabledField(BaseWorkspace.GridDataset, 'BuildingID')); } else if (pcDetails.ActivePage.Name == pgChangeLogContract.Name) { RefreshChangeLogContract(); } else if (pcDetails.ActivePage.Name == pgPaymentNotTied.Name) { RefreshCommonDetail(BaseWorkspace, wndPaymentNotTied,'ObjectID', 'NotTiedObjectID'); } } function PrepareChangeLogContract() { return; if (!System.GetHasLicense('DatabaseLog')) { ObjectsWorkspace.ShowChangesLogContractDetail = false; } else { ObjectsWorkspace.ContractLogTable = BaseWorkspace.GridDataset. DataFields('ContractID').LookupDataset.SelectQuery.Items(0).FromTable; ObjectsWorkspace.ShowChangesLogContractDetail = ObjectsWorkspace.GridTable.IsTrackChanges; } pgChangeLogContract.IsAccessible = ObjectsWorkspace.ShowChangesLogContractDetail; if (ObjectsWorkspace.ShowChangesLogContractDetail) { pgChangeLogContract.IsVisible = true; } else { return; } ObjectsWorkspace.ChangeLogContractWindow = wndChangeLogContract.Window; if (!ParentItemIDName) { ObjectsWorkspace.ParentItemIDName = 'ContractID'; } else { ObjectsWorkspace.ParentItemIDName = ParentItemIDName; } ObjectsWorkspace.InitializeChangesLogFlag = false; } function RefreshChangeLogContract() { return; var ChangesLogWindow = ObjectsWorkspace.ChangeLogContractWindow; var ParentItemID = null; if (ObjectsWorkspace.GridDataset.IsActive) { ParentItemID = ObjectsWorkspace.GridDataset. ValAsGUID(ObjectsWorkspace.ParentItemIDName); } if (ObjectsWorkspace.InitializeChangesLogFlag != true) { var IsBuildChangesLogWindow = BuildChangesLogWindow( ObjectsWorkspace.GridTable, ObjectsWorkspace.GridDataset, 'COntractID', ParentItemID, ChangesLogWindow); if (!IsBuildChangesLogWindow) { BaseWorkspace.ShowChangesLogDetail = false; Log.Write(2, "Ошибка при попытке показать журнал изменений"); } ObjectsWorkspace.InitializeChangesLogFlag = true; } else { var ChangesLogDataset = ObjectsWorkspace.ChangeLogContractWindow.ComponentsByName('dlData').Dataset; RefreshDetailData(BaseWorkspace.GridDataset, 'ContractID', ChangesLogDataset, 'RecordID'); } var btnOperations = ChangesLogWindow.ComponentsByName('btnOperations'); btnOperations.IsEnabled = !IsEmptyGUID(ParentItemID); } function RefreshLayoutDetail() { if (ObjectsWorkspace.InitializeDescriptionFlag != true) { InitializeLayoutDetail(); ObjectsWorkspace.InitializeDescriptionFlag = true; } var ObjectID = BaseWorkspace.GridDataset.ValAsGUID('ID'); if (ObjectID == ObjectsWorkspace.LayoutOldObjectID) { return; } else { ObjectsWorkspace.LayoutOldObjectID = ObjectID; } RefreshDetailData(BaseWorkspace.GridDataset, 'ID', ObjectsWorkspace.LayoutDataset, 'ID'); } function InitializeLayoutDetail() { ObjectsWorkspace.LayoutDataset = wndLayoutDetail.Window. ComponentsByName('dlData').Dataset; } function GetObjectIDFromWorkspace() { if (pcData.ActivePage.Name == 'pgGridData') { return dlObjects.Dataset.ValAsGUID('ID'); } if (pcData.ActivePage.Name == 'pgCheckerboard') { var Column = wndCheckerboard.Window('grdData').SelectedColumn; if (IsEmptyValue(Column)) { return; } var Field = Column.DataField; if (IsEmptyValue(Field)) { return; } if (IsEmptyValue(Field.Tag)) { return; } var FieldValue = dlCheckerboard.Dataset(Field.Tag); var FieldInfo = ParseFieldValue(FieldValue); if (IsEmptyValue(FieldInfo)) { return; } return FieldInfo.ID; } } // ---------------------------------------------------------------------------- // Event handlers // ---------------------------------------------------------------------------- function ReportMenuItemOnExecute(ActionMenuItem) { scr_BaseWorkspace.ReportMenuItemOnExecute(ActionMenuItem); } function wnd_ObjectsWorkspaceOnPrepare(Window) { Initialize(); btnLegend.IsVisible = (pcData.ActivePage.Name == 'pgCheckerboard'); UpdateControl(); amiSetAccessToFlats.IsVisible = Connector.CurrentUser.IsAdmin; RecalcCheckerboard(); amiReportSoldObjects.IsVisible = false; } function UpdateControl() { var TypeID = edtType.Value; var IsObjectID = !!edtObject.Value; var IsBuildingID = !!edtBuilding.Value; var IsParking = (TypeID == objcttpParking); edtBuilding.IsEnabled = (IsObjectID); edtSection.IsEnabled = ((IsBuildingID) && (!IsParking)); edtCompartment.IsEnabled = ((IsBuildingID) && (IsParking)); } function dlGroupsOnDatasetAfterPositionChange(Dataset) { scr_BaseWorkspace.dlGroupsOnDatasetAfterPositionChange(Dataset); if (BaseWorkspace.GroupsWereInitialized){ RefreshObjects(); } } function dlObjectsOnDatasetAfterPositionChange(Dataset) { if (Dataset.Attributes('IsNew') != true) { RefreshDetails(); } Dataset.Attributes('IsNew') = false; if (!ObjectsWorkspace.NotRefreshFilters) { //edtBuilding.Value = GetDatasetFieldValue(Dataset, 'BuildingID'); //edtSection.Value = GetDatasetFieldValue(Dataset, 'SectionID'); } } function pcDetailsOnChangeActivePage(Pages) { RefreshDetails(GetObjectIDFromWorkspace()); } function dlObjectsOnDatasetRefreshRecord(Dataset, KeyValue, AddNewRecordOnPage) { if (AddNewRecordOnPage) { AddItemInGroup(BaseWorkspace.GroupsDataset, 'ds_ObjectsInGroup', KeyValue, 'ObjectsID'); RefreshDetails(); } } function dlGroupsOnDatasetRefreshRecord(Dataset, KeyValue, AddNewRecordOnPage) { scr_BaseWorkspace.dlGroupsOnDatasetRefreshRecord(Dataset, KeyValue, AddNewRecordOnPage); RefreshObjects(); } function wnd_ObjectsWorkspaceOnNotify(ScriptableService, Sender, Message, Data) { if ((Message == MSG_GROUPSCHANGED) && (pcDetails.ActivePage.Name == pgGroupsDetail.Name)) { RefreshObjectsGroupsDetail(); return; } if (Message == 'REFRESH_CHECKERBOARD') { RefreshDetails(Data); return; } /* MODULE WORKFLOW */ if ((Message == 'MSG_OK') && (Sender.Tag == 'StartWorkflow')) { var WorkflowID = Sender.Attributes('KeyValue'); var ParamNames = new Array(); var ParamValues = new Array(); ParamNames.push('ObjectID'); ParamValues.push(ObjectsWorkspace.ObjectID); ObjectsWorkspace.ObjectID = null; WFStartByID(WorkflowID, ParamNames, ParamValues); return; } /* ENDMODULE WORKFLOW */ scr_BaseWorkspace.wnd_BaseWorkspaceOnNotify( ScriptableService, Sender, Message, Data); } function dlObjectsOnDatasetBeforeOpen(Dataset) { var IsInSingleRowMode = GetIsInSingleRowMode(); if (IsInSingleRowMode != true) { ApplyStandardWorkspaceFilter(); var ObjectID = edtObject.Value; var BuildingID = edtBuilding.Value; var SectionID = edtSection.Value; ApplyDatasetFilter(Dataset, 'ObjectID', ObjectID, !IsEmptyValue(ObjectID)); ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, !IsEmptyValue(BuildingID)); ApplyDatasetFilter(Dataset, 'SectionID', SectionID, !IsEmptyValue(SectionID)); ApplyDatasetFilter(Dataset, 'ObjectTypeID', edtType.Value, !IsEmptyValue(edtType.Value)); ApplyDatasetFilter(Dataset, 'CompartmentID', edtCompartment.Value, !IsEmptyValue(edtCompartment.Value)); ApplyDatasetFilter(Dataset, 'Name', edtName.Value, !IsEmptyValue(edtName.Value)); ApplyDatasetFilter(Dataset, 'StateID', edtStatus.Value, !IsEmptyValue(edtStatus.Value)); ApplyDatasetFilter(Dataset, 'ReservationID', edtReservation.Value, !IsEmptyValue(edtReservation.Value)); var ExistContract = edtExistContract.Value; if(ExistContract) { var Group = GetDatasetFieldValuesByID('ds_ContractGroup',ExistContract,'IsFiltered','FilterData'); var Filter = Dataset.SelectQuery.Items(0).Filters.Items(0)('ExistContractFilter'); var Query = Filter.TestExpression.ExpressionSelectQuery; Filter.IsEnabled = true; if(Group('IsFiltered')) { var IDs = GetFilterBuider(ExistContract,dlContractGroup.Dataset); ApplySelectQueryIncludeFilter(Query,'ContractIDs',IDs,true,null,Dataset.SelectQuery.Parameters); EnableSelectQueryFilters(Query, IDs.length==0, ['GroupID']); } else { EnableSelectQueryFilters(Query, false, ['ContractIDs']); EnableSelectQueryFilters(Query, true, ['GroupID']); } SetParameterValue(Dataset.SelectQuery.Parameters,'ExistContractFilter',ExistContract); } var NotExistsContract = edtNotExistsContract.Value; if(NotExistsContract) { var Group = GetDatasetFieldValuesByID('ds_ContractGroup',NotExistsContract,'IsFiltered','FilterData'); var Filter = Dataset.SelectQuery.Items(0).Filters.Items(0)('NotExistContractFilter'); var Query = Filter.TestExpression.ExpressionSelectQuery; Filter.IsEnabled = true; if(Group('IsFiltered')) { var IDs = GetFilterBuider(ExistContract,dlContractGroup2.Dataset); ApplySelectQueryIncludeFilter(Query,'ContractIDs',IDs,true,null,Dataset.SelectQuery.Parameters); EnableSelectQueryFilters(Query, IDs.length==0, ['GroupID']); } else { ApplySelectQueryFilter(Query,'GroupID',ExistContract,true); EnableSelectQueryFilters(Query, true, ['GroupID']); } SetParameterValue(Dataset.SelectQuery.Parameters,'ExistContractFilter',NotExistsContract); } var CheckerboardFilters = GetCheckerboardFilters(); if (CheckerboardFilters) { ApplyDatasetFilter(Dataset, 'FloorFrom', CheckerboardFilters.FloorFrom, !IsZeroValue(CheckerboardFilters.FloorFrom)); ApplyDatasetFilter(Dataset, 'FloorTo', CheckerboardFilters.FloorTo, !IsZeroValue(CheckerboardFilters.FloorTo)); ApplyDatasetFilter(Dataset, 'BasicAmountFrom', CheckerboardFilters.BasicAmountFrom, !IsZeroValue(CheckerboardFilters.BasicAmountFrom)); ApplyDatasetFilter(Dataset, 'BasicAmountTo', CheckerboardFilters.BasicAmountTo, !IsZeroValue(CheckerboardFilters.BasicAmountTo)); ApplyDatasetFilter(Dataset, 'RoomsFrom', CheckerboardFilters.RoomsFrom, !IsZeroValue(CheckerboardFilters.RoomsFrom)); ApplyDatasetFilter(Dataset, 'RoomsTo', CheckerboardFilters.RoomsTo, !IsZeroValue(CheckerboardFilters.RoomsTo)); } else { EnableDatasetFilters(Dataset, false, 'FloorFrom', 'FloorTo', 'BasicAmountFrom', 'BasicAmountTo', 'RoomsFrom', 'RoomsTo'); } } } function GetFilterBuider(GroupID,FilterDataset) { var dsContract = dlContractFilter.Dataset; if(!ObjectsWorkspace.ContractBuilder) { ObjectsWorkspace.ContractBuilder = System.CreateObject('TSObjectLibrary.FiltersBuilder'); ObjectsWorkspace.ContractBuilder.Dataset = dsContract; } var Filter = ObjectsWorkspace.ContractBuilder; Filter.FilterDataset = FilterDataset; Filter.FilterDataFieldName = 'FilterData'; Filter.UseDummyFilter = true; Filter.Load(); Filter.ApplyFilter(); RefreshDataset(dsContract); var IDs = new Array(); for(;!dsContract.IsEOF;dsContract.GoToNext()) { IDs.push(dsContract('ID')); } dsContract.Close(); return IDs; } function edtSectionOnPrepareSelectWindow(LookupControl, SelectWindow) { var Dataset = LookupControl.LookupDatasetLink.Dataset; var BuildingID = edtBuilding.Value; ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, true); } function edtSectionOnChange(LookupControl) { if (ObjectsWorkspace.DisableSectionControl) { return; } if (!IsEmptyValue(LookupControl.Value)) { edtBuilding.Value = GetDatasetFieldValueByID('ds_Section', LookupControl.Value, 'BuildingID'); edtCompartment.Value = null; } RecalcCheckerboard(); RebuildCheckboard(); edtCompartment.UnPrepareDropDownList(); //btnApplyFilterOnClick(LookupControl); } function RecalcCheckerboard() { if (IsEmptyValue(edtBuilding.Value) && (pcData.ActivePage.Name == pgCheckerboard.Name)) { wndCheckerboard.Window('dlData').Dataset.Close(); btnApplyFilter.IsEnabled = false; } else { btnApplyFilter.IsEnabled = true; } } function btnApplyFilterOnClick(Control) { var SectionID = edtSection.Value; var BuildingID = edtBuilding.Value; var GroupID = GetSelectedGroupID(); ObjectsWorkspace.NotRefreshFilters = true; RefreshObjects(); if (!IsEmptyValue(SectionID) || !IsEmptyValue(BuildingID)) { InitializeCheckerboard(BuildingID, SectionID); } var IsExtended = chbIsExtended.IsChecked; var CheckerboardFilters = GetCheckerboardFilters(); wndCheckerboard.Window.Attributes('CheckerboardFilters') = CheckerboardFilters; wndCheckerboard.Window.Attributes('ObjectsFilteredIDs') = GetObjectsFilteredIDs(CheckerboardFilters) if (!IsEmptyValue(BuildingID)) { InitializeCheckerboard(BuildingID, SectionID, GroupID, IsExtended); } ObjectsWorkspace.NotRefreshFilters = null; } function edtBuildingOnChange(LookupControl) { ObjectsWorkspace.DisableSectionControl = true; if (edtObject.Value == null) { var BuildingID = edtBuilding.Value; if (BuildingID != null) { edtObject.Value = GetDatasetFieldValueByID('ds_Building', BuildingID, 'ObjectID') } } edtSection.Value = null; ObjectsWorkspace.DisableSectionControl = false; edtSection.UnPrepareDropDownList(); edtCompartment.UnPrepareDropDownList(); RecalcCheckerboard(); RebuildCheckboard(); //btnApplyFilterOnClick(LookupControl); UpdateControl(); } function amiCreateContractOnExecute(ActionMenuItem, Sender) { var ObjectID = GetObjectIDFromWorkspace(); if (IsEmptyValue(ObjectID)) { ShowInformationDialog('Объект не выбран!'); return; } var Result = GetDatasetFieldValuesByID('ds_Objects', ObjectID, 'AccountID', 'Amount', 'BuilderID', 'ContactID', 'InventoryPrice', 'ObjectTypeID'); var Dataset = GetSingleItemByCode('ds_Contract', 'amiCreateContractOnExecute'); Dataset.Append(); var ContractID = Connector.GenGUID(); Dataset('ID') = ContractID; Dataset('OwnerID') = Connector.CurrentUser.ContactID; Dataset('StartDate') = GetLocalDate(); Dataset('DueDate') = GetLocalDate(); Dataset('CustomerID') = Result('AccountID'); if (Result('ObjectTypeID') == cntOTFlat) { Dataset('AmountWoNDS') = Result('Amount'); } Dataset('BuilderID') = Result('BuilderID'); Dataset('ContactID') = Result('ContactID'); Dataset('ObjectID') = ObjectID; Dataset('Amount') = Result('Amount'); Dataset.Post(); Dataset.Close(); if (mrYes == ShowConfirmationDialog("Перейти к созданной записи?")) { GotoWorkspace('wnd_ContractsWorkspace', ContractID) }; } function amiChangePriceByMeterOnExecute(ActionMenuItem, Sender) { var Win = Services.GetNewItemByUSI('wnd_ChangePriceByMeter'); Win.IsDesigning = false; Win.Prepare(); Win.Show(); } function btnLegendOnClick(Control) { var wnd = Services.GetNewItemByUSI('wnd_CheckerboardColorGridArea'); wnd.Attributes('IsWorkspace') = true; wnd.Attributes('HideButtonsFrame') = true; wnd.Prepare(); wnd.Show(); } function pcDataOnChangedActivePage(Pages) { scr_BaseWorkspace.pcDataOnChangedActivePage(Pages); btnLegend.IsVisible = (Pages.ActivePage.Name == 'pgCheckerboard'); RebuildCheckboard(); } function pcDataOnChangeActivePage(Pages) { RecalcCheckerboard(); } function amiSetAccessToFlatsOnExecute(ActionMenuItem, Sender) { var Attr = GetNewDictionary(); Attr('BuildingID') = edtBuilding.Value; Attr('SectionID') = edtSection.Value; ShowEditWindowEx('wnd_SetAccessToFlats', Attr); } function amiReportSoldObjectsOnExecute(ActionMenuItem, Sender) { var HasRights = GetIsCurrentUserHas(auTopManagers) || GetIsCurrentUserHas(auProjectManager) || GetIsCurrentUserHas(auDOManager) || GetIsCurrentUserHas(auCRMCoord) || GetIsCurrentUserHas(auCentralOffice); if (!HasRights) { ShowWarningDialog("У Вас недостаточно прав для запуска отчета"); return; } ShowEditWindowEx('wnd_ReportSoldProjects'); } function amiRunWorkflowOnExecute(ActionMenuItem, Sender) { var WindowCaption = "Процессы"; ObjectsWorkspace.ObjectID = dlObjects.Dataset.ValAsGUID('ID'); SelectServiceByCode('WorkflowDiagram', false, Self, 'StartWorkflow', WindowCaption); } function edtBuildingOnPrepareSelectWindow(LookupControl, SelectWindow) { var Dataset = LookupControl.LookupDatasetLink.Dataset; var ObjectID = edtObject.Value; ApplyDatasetFilter(Dataset, 'ObjectID', ObjectID, true); } function edtProjectOnChange(LookupControl) { edtBuilding.Value = null; } function GetSelectedGroupID() { var GroupsWindow = wndGroups.Window; var GroupsDataset = GroupsWindow.ComponentsByName('dlData').Dataset; var SelectedGroupID = GroupsDataset.Values('ID'); return SelectedGroupID; } function GetObjectsInGroupIDs() { var GroupID = GetSelectedGroupID(); var SectionID = edtSection.Value; var BuildingID = edtBuilding.Value; var ObjectsInGroupIDs = GetNewDictionary(); var Dataset = GetSingleItemByCode('ds_Objects','GetObjectsInGroupIDs'); ApplyDatasetFilter(Dataset, 'SectionID', SectionID, !IsEmptyValue(SectionID)); ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, !IsEmptyValue(BuildingID)); if (IsEmptyValue(GroupID)) { return ObjectsInGroupIDs; } var GroupDataset = GetGroupObjectsDataset(GroupID); var IsFiltered = !!GroupDataset('IsFiltered'); var ParentGroupID = GroupDataset('IsFiltered'); if (IsEmptyValue(ParentGroupID)) { ObjectsInGroupIDs; } ApplyDatasetFilter(Dataset, 'GroupID', GroupID, !IsFiltered); var FilterBuilder = GetObjectsFilterBilder(Dataset); if (IsFiltered) { //динамика if (!Assigned(FilterBuilder.FilterDataset)) { FilterBuilder.FilterDataset = GroupDataset; } FilterBuilder.Load(); FilterBuilder.ApplyFilter(); } else { //статика FilterBuilder.ClearFilter(); } Dataset.Open(); try { if (IsDatasetEmpty(Dataset)) { return ObjectsInGroupIDs; } while (!Dataset.IsEOF) { ObjectsInGroupIDs(Dataset('ID')) = true; Dataset.GotoNext(); } } finally { Dataset.Close(); } return ObjectsInGroupIDs; } function GetCheckerboardFilters() { var CheckerboardFilters = new Object(); CheckerboardFilters.FloorFrom = edtFloorFrom.Value; CheckerboardFilters.FloorTo = edtFloorTo.Value; CheckerboardFilters.BasicAmountFrom = edtBasicAmountFrom.Value; CheckerboardFilters.BasicAmountTo = edtBasicAmountTo.Value; CheckerboardFilters.RoomsFrom = edtRoomsFrom.Value; CheckerboardFilters.RoomsTo = edtRoomsTo.Value; if (IsZeroValue(CheckerboardFilters.FloorFrom) && IsZeroValue(CheckerboardFilters.FloorTo) && IsZeroValue(CheckerboardFilters.BasicAmountFrom) && IsZeroValue(CheckerboardFilters.BasicAmountTo) && IsZeroValue(CheckerboardFilters.RoomsFrom) && IsZeroValue(CheckerboardFilters.RoomsTo)) { return null; } return CheckerboardFilters; } function GetObjectsFilteredIDs(CheckerboardFilters) { var GroupID = GetSelectedGroupID(); var SectionID = edtSection.Value; var BuildingID = edtBuilding.Value; var ObjectsFilteredIDs = GetNewDictionary(); if (IsEmptyValue(CheckerboardFilters)) { return ObjectsFilteredIDs; } var Dataset = GetSingleItemByCode('ds_Objects','GetObjectsFilteredIDs'); ApplyDatasetFilter(Dataset, 'SectionID', SectionID, !IsEmptyValue(SectionID)); ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, !IsEmptyValue(BuildingID)); ApplyDatasetFilter(Dataset, 'FloorFrom', CheckerboardFilters.FloorFrom, !IsZeroValue(CheckerboardFilters.FloorFrom)); ApplyDatasetFilter(Dataset, 'FloorTo', CheckerboardFilters.FloorTo, !IsZeroValue(CheckerboardFilters.FloorTo)); ApplyDatasetFilter(Dataset, 'BasicAmountFrom', CheckerboardFilters.BasicAmountFrom, !IsZeroValue(CheckerboardFilters.BasicAmountFrom)); ApplyDatasetFilter(Dataset, 'BasicAmountTo', CheckerboardFilters.BasicAmountTo, !IsZeroValue(CheckerboardFilters.BasicAmountTo)); ApplyDatasetFilter(Dataset, 'RoomsFrom', CheckerboardFilters.RoomsFrom, !IsZeroValue(CheckerboardFilters.RoomsFrom)); ApplyDatasetFilter(Dataset, 'RoomsTo', CheckerboardFilters.RoomsTo, !IsZeroValue(CheckerboardFilters.RoomsTo)); Dataset.Open(); try { if (IsDatasetEmpty(Dataset)) { return ObjectsFilteredIDs; } while (!Dataset.IsEOF) { ObjectsFilteredIDs(Dataset('ID')) = true; Dataset.GotoNext(); } } finally { Dataset.Close(); } return ObjectsFilteredIDs; } function amiSummaryReportOnExecute(ActionMenuItem, Sender) { var wnd = Services.GetNewItemByUSI('wnd_SummaryReportFilter'); wnd.Prepare(); wnd.Show(); } function amiNewFormOnExecute(ActionMenuItem, Sender) { var wnd = Services.GetNewItemByUSI('wnd_SummaryReportFilter2'); wnd.Prepare(); wnd.Show(); } function amiSalePlanOnExecute(ActionMenuItem, Sender) { wnd = Services.GetNewItemByUSI('wnd_SalesPlan'); wnd.Attributes('fnFiles') = fnFiles; wnd.Show(); } function amiPlanExecutionOnExecute(ActionMenuItem, Sender) { wnd = Services.GetNewItemByUSI('wnd_PlanExecution'); wnd.Show(); } function amiLoadSalesPlanOnExecute(ActionMenuItem, Sender) { LoadSalesPlan(); } function fnFilesOnFileChange(FileChangeNotifier, FileName, FileID) { LoadSalesPlan(FileName); } function amiExportOnExecute(ActionMenuItem, Sender) { var wnd = Services.GetNewItemByUSI('wnd_ObjectsExportGridArea'); SetAttribute(wnd,'Export',true); wnd.Prepare(); wnd.Show(); } function RebuildCheckboard() { if(pcData.ActivePage.Name == 'pgCheckerboard') { wndCheckerboard.Window.Notify(Self,'Rebuild_Checkboard',edtSection.Value); } } function edtObjectOnChange(LookupControl) { edtBuilding.UnprepareDropDownList(); edtBuilding.DisableEvents(); edtSection.DisableEvents(); edtBuilding.Value = null; edtSection.Value = null; edtSection.EnableEvents(); edtBuilding.EnableEvents(); UpdateControl(); RebuildCheckboard(); } function edtCompartmentOnPrepareSelectWindow(LookupControl, SelectWindow) { var Dataset = LookupControl.LookupDatasetLink.Dataset; var BuildingID = edtBuilding.Value; var ObjectID = edtObject.Value; ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, !!BuildingID); ApplyDatasetFilter(Dataset, 'ObjectID', ObjectID, !!ObjectID); } function edtCompartmentOnChange(LookupControl) { edtObject.UnPrepareDropDownList(); edtSection.UnPrepareDropDownList(); if(edtCompartment.Value) { Compartment = GetDatasetFieldValuesByID('ds_Compartment',edtCompartment.Value,'ObjectID','BuildingID'); if(edtBuilding.Value!=Compartment('BuildingID')) edtBuilding.Value = Compartment('BuildingID'); if(edtObject.Value!=Compartment('ObjectID')) edtObject.Value = Compartment('ObjectID'); edtSection.Value = null; } } function edtTypeOnChange(LookupControl) { UpdateControl(); } function btnClearFilterOnClick(Control) { edtObject.Value = null; edtBuilding.Value = null; edtSection.Value = null; edtCompartment.Value = null; edtName.Value = ''; edtFloorFrom.Value = 0; edtFloorTo.Value = 0; edtBasicAmountFrom.Value = 0; edtBasicAmountTo.Value = 0; edtRoomsFrom.Value = 0; edtRoomsTo.Value = 0; RefreshObjects(); } function amiSalesPalnOnExecute(ActionMenuItem, Sender) { var wnd = Services.GetNewItemByUSI('wnd_SalesReport'); wnd.Show();//TODO }
например в этот кусок:
function GetObjectsFilteredIDs(CheckerboardFilters) { var GroupID = GetSelectedGroupID(); var SectionID = edtSection.Value; var BuildingID = edtBuilding.Value; var ObjectsFilteredIDs = GetNewDictionary(); if (IsEmptyValue(CheckerboardFilters)) { return ObjectsFilteredIDs; } var Dataset = GetSingleItemByCode('ds_Objects','GetObjectsFilteredIDs'); ApplyDatasetFilter(Dataset, 'SectionID', SectionID, !IsEmptyValue(SectionID)); ApplyDatasetFilter(Dataset, 'BuildingID', BuildingID, !IsEmptyValue(BuildingID)); ApplyDatasetFilter(Dataset, 'FloorFrom', CheckerboardFilters.FloorFrom, !IsZeroValue(CheckerboardFilters.FloorFrom)); ApplyDatasetFilter(Dataset, 'FloorTo', CheckerboardFilters.FloorTo, !IsZeroValue(CheckerboardFilters.FloorTo)); ApplyDatasetFilter(Dataset, 'BasicAmountFrom', CheckerboardFilters.BasicAmountFrom, !IsZeroValue(CheckerboardFilters.BasicAmountFrom)); ApplyDatasetFilter(Dataset, 'BasicAmountTo', CheckerboardFilters.BasicAmountTo, !IsZeroValue(CheckerboardFilters.BasicAmountTo)); ApplyDatasetFilter(Dataset, 'RoomsFrom', CheckerboardFilters.RoomsFrom, !IsZeroValue(CheckerboardFilters.RoomsFrom)); ApplyDatasetFilter(Dataset, 'RoomsTo', CheckerboardFilters.RoomsTo, !IsZeroValue(CheckerboardFilters.RoomsTo)); Dataset.Open(); try { if (IsDatasetEmpty(Dataset)) { return ObjectsFilteredIDs; } while (!Dataset.IsEOF) { ObjectsFilteredIDs(Dataset('ID')) = true; Dataset.GotoNext(); } } finally { Dataset.Close(); } return ObjectsFilteredIDs; }
Да, нужно добавить не только поле в дизайнере, но и дописать нужные скрипты, где происходит работа с ним. Не знаю, какую Вы хотите создать логику при работе с полем «подвал», возможно всё можно сделать аналогично полю SectionID (найти все места в скрипте, где оно упоминается и сделать то же самое со своим полем), а возможно и не аналогично, а как-то иначе.
Если у Вас возникают затруднения при самостоятельной разработке, Вы можете сформулировать свои требования и заказать услугу доработок у Terrasoft или у одного из их партнёров.
Спасибо, все получилось.
Вопрос по отчетам можно задавать здесь, или необходимо создать лучше новую тему?
Добрый день!
По каждому вопросу необходимо создавать отдельную тему.