Гость
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Можно ли с помощью dw rexpression получить значение (+) / 8 сообщений из 8, страница 1 из 1
26.03.2004, 16:01
    #32458876
Вовик
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
Можно ли с помощью dw rexpression получить значение
поля в dddw , отличное от DisplayColumn и DataColumn ?

Поясню : есть dw , на нем колонка с edit-style - dddw. В этом dddw
больше двух колонок . Те , что DisplayColumn и DataColumn - не интересуют.
Нужно в некотором другом compute - поле на том же dw отобразить значение
из dddw - колонки , которая не DisplayColumn и не DataColumn .

Можно ли сочинить такое выражение ?
...
Рейтинг: 0 / 0
26.03.2004, 16:25
    #32458928
Филипп
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
нет
...
Рейтинг: 0 / 0
26.03.2004, 16:34
    #32458952
Вовик
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
А я только что вот что придумал :

1) на dw кидаем новую колонку ( дубль той , в которой dddw )
2) ставим ей стиль редаитрования тоже dddw с тем же dddw , только с
другим ( НУЖНЫМ ) DisplayColumn -

и все работает:
как только выбираем что-нибудь в первом dddw - во втором все переотображается!
...
Рейтинг: 0 / 0
07.04.2004, 16:41
    #32472385
Komputilisto
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
Вот функция, возвращающая значение из другого поля DDDW (его тип должен быть числовым):
/*----------------------------------------------------------------------------------------------------------------------
uf_get_number_from_dwc(adw, al_row, as_col, as_dwc_col_dwc, as_val_to_search_by)
------------------------------------------------------------------------------------------------------------------------
Dscr: Retrurns a value of a NUMERIC column in a DataWindowChild. For example, we have
a column 'person_id', whose DDDW contains an invisible column 'birth_year'. When user
selects a person, we want automatically populate the invisible column 'birth_year'.
Here is the needed fragment of the ItemChanged script:

li_birth_year = uf_get_number_from_dwc(this, row, 'person_id', 'birth_year', data)
object.birth_year[row] = li_birth_year

The corresponding columns in the DW itself and in the Child can differ in their names;
in our example, the Data Column in the DWC can be named, for example, 'person_num'.
But when you call the function, pass to it the name of the column on the DW itself
'person_id'.

Caution! The conumn to search by ('person_id') must be numeric!
------------------------------------------------------------------------------------------------------------------------
Arg: adw - the DW itself (not the child!);
al_row - the row in the DW;
as_col - the column name in the DW (on which the DDDW is placed);
it can be of a numeric or string data type;
as_dwc_col_dwc - the column name in the Child whose value the function
will return; it must be of a numeric data type;
as_val_to_search_by - the value by which to search as a string; if the data column
is numeric - cast the value to string before.
------------------------------------------------------------------------------------------------------------------------
Ret: the found value (datetime)
----------------------------------------------------------------------------------------------------------------------*/
int li_dwc_row
dec ldec_return
string ls_dwc_data_col
string ls_serch_expr
string ls_col_with_dddw_type
DataWindowChild ldwc

ls_dwc_data_col = adw.Describe(as_col + '.dddw.datacolumn')
ls_col_with_dddw_type = adw.Describe(as_col + ".coltype")
ls_col_with_dddw_type = Lower(Left(ls_col_with_dddw_type, 4))
adw.GetChild(as_col, ref ldwc)

if ls_col_with_dddw_type = 'char' then
ls_serch_expr = ls_dwc_data_col + '="' + as_val_to_search_by + '"'
else
ls_serch_expr = ls_dwc_data_col + '=' + as_val_to_search_by
end if

li_dwc_row = ldwc.Find(ls_serch_expr, 1, ldwc.RowCount())
if li_dwc_row < 1 then return ii_null
ldec_return = ldwc.GetItemNumber(li_dwc_row, as_dwc_col)

return ldec_return

Если сделать эту функцию глобальной (и, может, переделать, если надо), то её можно будет использовать в DW expressions как любую глобальную функцию. Я подобного не делал, так что только бросаю идею.
...
Рейтинг: 0 / 0
07.04.2004, 16:43
    #32472391
Komputilisto
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
Ошибка в комментарии функции:
Ret: the found value (decimal)
...
Рейтинг: 0 / 0
07.04.2004, 16:47
    #32472399
Komputilisto
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
Вот аналогичная функция, если невидимая колонка в DDDW - типа DateTime:
/*----------------------------------------------------------------------------------------------------------------------
uf_get_datetime_from_dwc(adw, al_row, as_col, as_dwc_col_dwc, as_val_to_search_by)
------------------------------------------------------------------------------------------------------------------------
Dscr: Retrurns a value of a DATETIME column in a DataWindowChild. For example, we have
a column 'person_id', whose DDDW contains an invisible column 'birth_date'. When user
selects a person, we want automatically populate the invisible column 'birth_date'.
Here is the needed fragment of the ItemChanged script:

ldt_birth_date = uf_get_datetime_from_dwc(this, row, 'person_id', 'birth_date', data)
object.birth_date[row] = ldt_birth_date

The corresponding columns in the DW itself and in the Child can differ in their names;
in our example, the Data Column in the DWC can be named, for example, 'person_num'.
But when you call the function, pass to it the name of the column on the DW itself
'person_id'.

Caution! The conumn to search by ('person_id') must be numeric!
------------------------------------------------------------------------------------------------------------------------
Arg: adw - the DW itself (not the child!);
al_row - the row in the DW;
as_col - the column name in the DW (on which the DDDW is placed);
it can be of a numeric or string data type;
as_dwc_col_dwc - the column name in the Child whose value the function
will return; it must be of a numeric data type;
as_val_to_search_by - the value by which to search as a string; if the data column
is numeric - cast the value to string before.
------------------------------------------------------------------------------------------------------------------------
Ret: the found value (datetime)
----------------------------------------------------------------------------------------------------------------------*/
datetime ldt_return
int li_dwc_row
string ls_dwc_data_col
string ls_serch_expr
string ls_col_with_dddw_type
DataWindowChild ldwc

ls_dwc_data_col = adw.Describe(as_col + '.dddw.datacolumn')
ls_col_with_dddw_type = adw.Describe(as_col + ".coltype")
ls_col_with_dddw_type = Lower(Left(ls_col_with_dddw_type, 4))
adw.GetChild(as_col, ref ldwc)

if ls_col_with_dddw_type <> 'char' then
ls_serch_expr = ls_dwc_data_col + '=' + as_val_to_search_by
else
ls_serch_expr = ls_dwc_data_col + '="' + as_val_to_search_by + '"'
end if

li_dwc_row = ldwc.Find(ls_serch_expr, 1, ldwc.RowCount())
if li_dwc_row < 1 then return idt_null
ldt_return = ldwc.GetItemDateTime(li_dwc_row, as_dwc_col)

return ldt_return

(извиняюсь, что загадил ветку скриптами - может, они и не пригодятся)
...
Рейтинг: 0 / 0
07.04.2004, 17:04
    #32472457
Вовик
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
Спасибо большое за скрипты !
Хотя я уже изложил выше решение , которое меня устраивает : отображение с помощью колонки - дубля.

PS
А если не секрет , откуда эти скрипты ?
...
Рейтинг: 0 / 0
14.04.2004, 18:21
    #32481661
Komputilisto
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Можно ли с помощью dw rexpression получить значение (+)
"А если не секрет , откуда эти скрипты ?"
Да я более, чем 3 года работы на PB собирал разные полезные функции в NVO и носил его из проекта в проект, чтоб не изобратать велосипед. Проекты и так были непростые, и опыта у меня мало, так я им что, Кулибин, что-ли, изобретать всё время - а NVO всё время со мной.
...
Рейтинг: 0 / 0
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Можно ли с помощью dw rexpression получить значение (+) / 8 сообщений из 8, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]