AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.10.2006, 13:09   #1  
iolanna is offline
iolanna
Участник
 
38 / 10 (1) +
Регистрация: 25.10.2006
Thumbs up
Объясните фильтрацию, CALCFIELDS, SETFILTER и др.
Когда и как их применять!
Когда подходит один, когда другой!
Старый 11.10.2006, 13:47   #2  
randrews is offline
randrews
Участник
Аватар для randrews
 
312 / 10 (1) +
Регистрация: 06.12.2004
Цитата:
Сообщение от iolanna Посмотреть сообщение
Объясните фильтрацию, CALCFIELDS, SETFILTER и др.
Когда и как их применять!
Когда подходит один, когда другой!
CALCFIELDS - это не фильтрация. Это расчет поля с типом Flowfield.

SETFILTER и SETRANGE используются для фильтрации.
SETRANGE(Field,от значения [, до значения])
SETFILTER(Field,'сложный фильтр',значение1, значение2, ....) -

Кстати по F1 очень подробно описано



SETRANGE (Record)
Use this function to set a simple filter, such as a single range or a single value, on a field.

Record.SETRANGE(Field [,FromValue] [.ToValue])
Record

Data type: record

The record that contains the field you want to filter.

Field

Data type: field

The field you want to filter.

FromValue

Data type: -

The lower limit of the range. The type of FromValue must match Field.

ToValue

Data type: -

The upper limit of the range. If you omit this parameter, the system uses the value you specified for FromValue. The type of ToValue must match Field.

Comments
SETRANGE provides a quick way to set a simple filter on a field. If you call this function with a field that already has a filter, the system removes that filter before it sets the new one. If you omit all of the optional parameters, the system removes any and all filters set for Field.

The fieldref function fails if no field is selected.

Example
This example shows how to use the SETRANGE function to specify that you only want to see customers 100 through 200.

Customer.SETRANGE("No.", '100', '200');

The above statement is a quick way to set the same filter as:

Customer.SETFILTER("No.", '>=100&<=200');





SETFILTER (Record)
Use this function to assign a filter to a field you specify.

Record.SETFILTER(Field, String, [Value],...)
Record

Data type: record

The record that contains the field you want to filter.

Field

Data type: field

The field you want to filter.

String

Data type: text or code

The filter expression. A valid expression consists of alphanumeric characters and one or more of the following operators: <, >, *, &, |, and =. You can use replacement fields (%1, %2, and so on) to insert values at run-time.

Value

Data type: any

Replacement values to insert in replacement fields in the filter expression. The data type of Value must match the type of Field.

Comments
If the function is called with a field for which a filter already exists, the system will remove that filter before it sets the new one. You can construct filters using these operators:

This operator...
Means...

..
Range

&
And

|
Or

<
Less than

<=
Less than or equal to

>
Greater than

>=
Greater than or equal to

<>
Different from

*
Forms a part of value


Example
This table shows examples of filters:

This example...
Means...

A..Z
A range from A to Z

A | G
A or G

F.. & *A/S
A range from F and A/S is included in the field.

<>B
All except B

<>''
All not blank

<=200 | >500
All less than or equal to 200 or greater than 500


Using a filter with replacement field:

This filter selects all accounts in the range from 100 to 200 and No. 300

"G/L Account".SETFILTER("No.", '%1..%2|%3', '100', '200', '300');

Using a filter entered directly in a string:

This filter, which is entered as a string, corresponds to the previous example. It too selects all accounts in the range from 100 to 200 and No. 300.

"G/L Account".SETFILTER("No.", '100..200|300');
Старый 11.10.2006, 13:53   #3  
romeo is offline
romeo
Участник
Аватар для romeo
 
564 / 10 (2) +
Регистрация: 31.03.2004
Цитата:
Сообщение от iolanna Посмотреть сообщение
Объясните фильтрацию, CALCFIELDS, SETFILTER и др.
Когда и как их применять!
Когда подходит один, когда другой!
Ок. Можно получить ответы на эти и другие элементарные вопросы. Мало того, что СПРАВКА даст на них ответы быстрее и полнее есть еще куски кода, которые нужно понять и грамотно вписаться со своими изменениями. Что делать с этим?? Иногда нужно проанализировать работу не одного юнита, чтобы выбрать место, куда лучше впихнуть свои модификации... Я фигею.
Старый 03.08.2007, 13:38   #4  
Padre is offline
Padre
Участник
 
28 / 12 (1) ++
Регистрация: 14.05.2007
Адрес: Санкт - Петербург
А вот скажите мне, что будет с таблицей если применить такой фильтр?
Table.SETFILTER(Code, '<>%1&<>%2', '', '10*');
Старый 03.08.2007, 15:21   #5  
Padre is offline
Padre
Участник
 
28 / 12 (1) ++
Регистрация: 14.05.2007
Адрес: Санкт - Петербург
Могу сказать что в данном случае таблица не отфильтруется, может кто нибудь знает почему?
Старый 03.08.2007, 15:25   #6  
Голышев Михаил is offline
Голышев Михаил
Участник
 
106 / 10 (1) +
Регистрация: 03.07.2006
Это косяк SETFILTER

делайте так:
Table.SETFILTER(Code, STRSUBSTNO('<>%1&<>%2', '''''', '10*'));
Старый 03.08.2007, 15:35   #7  
Padre is offline
Padre
Участник
 
28 / 12 (1) ++
Регистрация: 14.05.2007
Адрес: Санкт - Петербург
Спасибо, надо попробовать
Старый 26.09.2007, 10:22   #8  
Critic is offline
Critic
Участник
Аватар для Critic
 
13 / 10 (1) +
Регистрация: 17.03.2006
StrFilter:=1|2|3|4|5|6|7|8 и тд (заполняется на форме пользователем)
размер поля на фильтрацию - 5

Table.SETFILTER(Code, STRSUBSTNO(StrFilter));

снимает глюк со строкой фильтра больше размерности поля на Nav 3.77

Респект автору.
__________________
Ведрусса. Я не волшебник, а только учусь
Старый 28.09.2007, 14:17   #9  
grif is offline
grif
Участник
Аватар для grif
 
236 / 10 (1) +
Регистрация: 31.08.2006
Цитата:
Сообщение от golyshev Посмотреть сообщение
Это косяк SETFILTER
делайте так:
Table.SETFILTER(Code, STRSUBSTNO('<>%1&<>%2', '''''', '10*'));
и в тройке фильтры типа <>10* работать не будут
Старый 01.10.2007, 13:11   #10  
Fordewind is offline
Fordewind
Участник
 
1,134 / 10 (3) +
Регистрация: 01.12.2005
Цитата:
Сообщение от grif Посмотреть сообщение
и в тройке фильтры типа <>10* работать не будут
Только если используется Native. На SQL должен работать
 

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:01.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.