Карточка контакта. Контрагент. LookupDataControl

З карточки контакта розкриваю LookupDataControl поля AccountID

function edtAccountOnPrepareSelectWindow(LookupDataControl, SelectWindow) {
        var Dataset = LookupDataControl.DataField.LookupDataset;
        EnableDatasetFilters(Dataset, false);
        if (Dataset && (Dataset.State == dstInactive)) {
                Dataset.Open();
        }
}

Перший раз вікно порожнє, а на другий вже наповнюється табличними даними.
І точно така ж ситуація на деталі Кар'єра:

function edtAccountOnPrepareSelectWindow(LookupDataControl, SelectWindow) {
        var Dataset = LookupDataControl.DataField.LookupDataset;
        EnableDatasetFilters(Dataset, false);
        if (Dataset && (Dataset.State == dstInactive)) {
                Dataset.Open();
        }
}

В чому причина такої поведінки LookupDataControl-елемента ?
І як заставити його показувати табличні дані з першого разу ?

Нравится

14 комментариев

Какой смысл в этом коде?

        if (Dataset && (Dataset.State == dstInactive)) {
                Dataset.Open();
        }

Событие OnPrepareSelectWindow позволяет применить фильтры к датасету выбора, но открывать датасет не надо, он сам откроется

То, власне, залишок пошуків причини такої поведінки елемента, - я намагався якось простимулювати процес :). Насправді там було всього більше, залишилось тільки це.
Тож сенсу в цьому і справді ніякого, бо ніяк не змінює реакцію елемента.

По идее не должно быть такого, что первый раз грид окна выбора пустой, а второй раз - уже с данными.
Проверьте, есть ли у ds_Account обработчик события OnBeforeOpen (может там фильтр включается).
И надо посмотреть профайлером, какой запрос идет к базе при открытии окна выбора.

OnBeforeOpen на ds_Account не активовано.
Користуюся SQLExpress 2008R2, профайлер відсутній.

Здравствуйсте Игорь,
Попробуйте дописать в функцию edtAccountOnPrepareSelectWindow строку

 PrepareLookupDataControl(LookupDataControl, dlData.Dataset);

предварительно проверив, подключен ли скпипт scr_WindowUtils

Группа компаний Terrasoft

Взявся подивитися на текст SQL-запиту

function edtAccountOnPrepareSelectWindow(LookupDataControl, SelectWindow) {
	var Dataset = LookupDataControl.DataField.LookupDataset;
	EnableDatasetFilters(Dataset, false);
 
	MessageBox(Connector.DBEngine.GetSelectQuerySQLText(Dataset.SelectQuery));
 
}

То видно, що при першому відкритті запит формується по повній структурі sq_Account,

SELECT
	[tbl_Account].[ID] AS [ID],
	[tbl_Account].[Name] AS [Name],
	[tbl_Account].[OfficialAccountName] AS [OfficialAccountName],
	[tbl_Account].[AnnualRevenue] AS [AnnualRevenue],
	[tbl_Account].[EmployeesNumber] AS [EmployeesNumber],
	[tbl_Account].[Address] AS [Address],
	[tbl_Account].[AddressTypeID] AS [AddressTypeID],
	[tbl_Account].[Communication1] AS [Communication1],
	[tbl_Account].[Communication1TypeID] AS [Communication1TypeID],
	[tbl_Account].[Communication2] AS [Communication2],
	[tbl_Account].[Communication2TypeID] AS [Communication2TypeID],
	[tbl_Account].[Communication3] AS [Communication3],
	[tbl_Account].[Communication3TypeID] AS [Communication3TypeID],
	[tbl_Account].[Communication4] AS [Communication4],
	[tbl_Account].[Communication4TypeID] AS [Communication4TypeID],
	[tbl_Account].[Communication5] AS [Communication5],
	[tbl_Account].[Communication5TypeID] AS [Communication5TypeID],
	[tbl_City].[Name] AS [CityName],
	[tbl_Account].[CityID] AS [CityID],
	[tbl_Account].[ZIP] AS [ZIP],
	[tbl_Campaign].[Name] AS [CampaignName],
	[tbl_Account].[CampaignID] AS [CampaignID],
	[tbl_Contact].[Name] AS [PrimaryContactName],
	[tbl_Account].[PrimaryContactID] AS [PrimaryContactID],
	[tbl_Country].[Name] AS [CountryName],
	[tbl_Account].[CountryID] AS [CountryID],
	[tbl_State].[Name] AS [StateName],
	[tbl_Account].[StateID] AS [StateID],
	[tbl_Territory].[Name] AS [TerritoryName],
	[tbl_Account].[TerritoryID] AS [TerritoryID],
	[Owner].[Name] AS [OwnerName],
	[tbl_Account].[OwnerID] AS [OwnerID],
	[tbl_Account].[ActivityID] AS [ActivityID],
	[tbl_Activity].[Name] AS [ActivityName],
	[tbl_Account].[FieldID] AS [FieldID],
	[tbl_Field].[Name] AS [FieldName],
	[tbl_Account].[AccountTypeID] AS [AccountTypeID],
	[tbl_AccountType].[Name] AS [AccountTypeName],
	[tbl_AddressType].[Name] AS [AddressTypeName],
	[CommunicationType1].[Name] AS [Communication1TypeName],
	[CommunicationType2].[Name] AS [Communication2TypeName],
	[CommunicationType3].[Name] AS [Communication3TypeName],
	[CommunicationType4].[Name] AS [Communication4TypeName],
	[CommunicationType5].[Name] AS [Communication5TypeName],
	[tbl_Account].[Code] AS [Code],
	[tbl_Account].[TaxRegistrationCode] AS [TaxRegistrationCode],
	[tbl_Account].[CreatedOn] AS [CreatedOn],
	[tbl_Account].[CreatedByID] AS [CreatedByID],
	[CreatedBy].[Name] AS [CreatedByName],
	[tbl_Account].[ModifiedOn] AS [ModifiedOn],
	[tbl_Account].[ModifiedByID] AS [ModifiedByID],
	[ModifiedBy].[Name] AS [ModifiedByName],
	[tbl_Job].[NameOf] AS [JobNameOf],
	[tbl_Account].[SettledCredit] AS [SettledCredit],
	[tbl_Account].[PostponementPayment] AS [PostponementPayment],
	[tbl_Account].[LegalPersonID] AS [LegalPersonID],
	[tbl_LegalPersons].[Name] AS [LegalPersonName],
	[tbl_LegalPersons].[FullName] AS [LegalPersonFullName],
	[tbl_Account].[StreetTypeID] AS [StreetTypeID],
	[tbl_StreetTypes].[Name] AS [StreetTypeName],
	[tbl_Account].[StreetID] AS [StreetID],
	[tbl_Streets].[Name] AS [StreetName],
	[tbl_Account].[House] AS [House],
	[tbl_Account].[Corps] AS [Corps],
	[tbl_Account].[Flat] AS [Flat]
FROM
	[dbo].[tbl_Account] AS [tbl_Account]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [tbl_Contact] ON [tbl_Contact].[ID] = [tbl_Account].[PrimaryContactID]
LEFT OUTER JOIN
	[dbo].[tbl_Territory] AS [tbl_Territory] ON [tbl_Territory].[ID] = [tbl_Account].[TerritoryID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [Owner] ON [Owner].[ID] = [tbl_Account].[OwnerID]
LEFT OUTER JOIN
	[dbo].[tbl_Campaign] AS [tbl_Campaign] ON [tbl_Campaign].[ID] = [tbl_Account].[CampaignID]
LEFT OUTER JOIN
	[dbo].[tbl_City] AS [tbl_City] ON [tbl_City].[ID] = [tbl_Account].[CityID]
LEFT OUTER JOIN
	[dbo].[tbl_State] AS [tbl_State] ON [tbl_State].[ID] = [tbl_Account].[StateID]
LEFT OUTER JOIN
	[dbo].[tbl_Country] AS [tbl_Country] ON [tbl_Country].[ID] = [tbl_Account].[CountryID]
LEFT OUTER JOIN
	[dbo].[tbl_Activity] AS [tbl_Activity] ON [tbl_Activity].[ID] = [tbl_Account].[ActivityID]
LEFT OUTER JOIN
	[dbo].[tbl_Field] AS [tbl_Field] ON [tbl_Field].[ID] = [tbl_Account].[FieldID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [CreatedBy] ON [CreatedBy].[ID] = [tbl_Account].[CreatedByID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [ModifiedBy] ON [ModifiedBy].[ID] = [tbl_Account].[ModifiedByID]
LEFT OUTER JOIN
	[dbo].[tbl_AddressType] AS [tbl_AddressType] ON [tbl_AddressType].[ID] = [tbl_Account].[AddressTypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType1] ON [CommunicationType1].[ID] = [tbl_Account].[Communication1TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType2] ON [CommunicationType2].[ID] = [tbl_Account].[Communication2TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType3] ON [CommunicationType3].[ID] = [tbl_Account].[Communication3TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType4] ON [CommunicationType4].[ID] = [tbl_Account].[Communication4TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType5] ON [CommunicationType5].[ID] = [tbl_Account].[Communication5TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_Job] AS [tbl_Job] ON [tbl_Job].[ID] = [tbl_Contact].[JobID]
LEFT OUTER JOIN
	[dbo].[tbl_AccountType] AS [tbl_AccountType] ON [tbl_AccountType].[ID] = [tbl_Account].[AccountTypeID]
LEFT OUTER JOIN
	[dbo].[tbl_LegalPersons] AS [tbl_LegalPersons] ON [tbl_LegalPersons].[ID] = [tbl_Account].[LegalPersonID]
LEFT OUTER JOIN
	[dbo].[tbl_StreetTypes] AS [tbl_StreetTypes] ON [tbl_StreetTypes].[ID] = [tbl_Account].[StreetTypeID]
LEFT OUTER JOIN
	[dbo].[tbl_Streets] AS [tbl_Streets] ON [tbl_Streets].[ID] = [tbl_Account].[StreetID]

а наступні - по скороченій:

SELECT TOP 40
	[tbl_Account].[ID] AS [ID],
	[tbl_Account].[Name] AS [Name],
	[tbl_Account].[OfficialAccountName] AS [OfficialAccountName],
	[tbl_Account].[Address] AS [Address],
	[tbl_Account].[Communication1] AS [Communication1],
	[tbl_City].[Name] AS [CityName],
	[tbl_Account].[CityID] AS [CityID],
	[tbl_Account].[CountryID] AS [CountryID],
	[tbl_Account].[StateID] AS [StateID],
	[tbl_Account].[TaxRegistrationCode] AS [TaxRegistrationCode]
FROM
	[dbo].[tbl_Account] AS [tbl_Account]
LEFT OUTER JOIN
	[dbo].[tbl_City] AS [tbl_City] ON [tbl_City].[ID] = [tbl_Account].[CityID]

Добавив у варіанті:

function edtAccountOnPrepareSelectWindow(LookupDataControl, SelectWindow) {
	PrepareLookupDataControl(LookupDataControl, dlData.Dataset);
	var Dataset = LookupDataControl.DataField.LookupDataset;
	EnableDatasetFilters(Dataset, false);
}

На жаль це не змінило стану речей.

Игорь, выгрузите пожалуйста сервисы карточки и датасет который вы используете. Для того что бы мы могли воспроизвести проблему.

Тут, начебто, всі сервіси, що можуть мати стосунок до роботи карточки
...
Переприкріпив файл ...

http://www.community.terrasoft.ru/system/files/files_1.rar
Запрашиваемая страница не найдена

Просьба прикрепить еще раз

Прикріпив заново

http://www.community.terrasoft.ru/system/files/files_0.rar
Запрашиваемая страница не найдена

Игорь, как вариант напишите нам письмо на support@tscrm.com, или загрузите файл на файлообменник.

Написав

Игорь, к сожалению на ваших сервисах не удалось воспроизвести проблему описанную вами/
Если есть возможность, отправьте, пожалуйста, ссылку на копию базы данных на адрес Службы поддержки Terrasoft (support@tscrm.com) для анализа проблемы.

Показать все комментарии