When adding ranges to datasources in code, you sometimes don't want the user to alter the range in any way. Sometimes it is also necessary to hide the applied range.
To lock or hide the range, use the status method of the QueryBuildRange class. The following code creates a hidden range of the field MyField to empty string.
The user will not be able to see or change the range of the field MyField.QueryBuildRange qbrExampleRange; qbrExampleRange = MyDatasource_ds.query().dataSourceTable(tableNum(MyTable)) .addRange(fieldNum(MyTable, MyField)); qbrExampleRange.value(SysQuery::valueEmptyString()); qbrExampleRange.status(RangeStatus::Hidden);
Similarly the following code sets the field Department to "HQ". This time setting the range status to Locked.
The user will be able to see that there is a "HQ" filter on the Department field, but not able to remove it or change the value.QueryBuildRange qbrDepartmentRange; qbrDepartmentRange = MyDatasource_ds.query().dataSourceTable(tableNum(MyTable)) .addRange(fieldNum(MyTable, Department)); qbrDepartmentRange.value(SysQuery::value('HQ')); qbrDepartmentRange.status(RangeStatus::Locked);
No comments:
Post a Comment