Oracle Apex弹出式LOV应该显示完整的数字,但网格仅显示前4位数字。

huangapple go评论69阅读模式
英文:

Oracle Apex pop up lov should show full number but grid display only first 4 digits

问题

select emp_name,substr (dept_name,2) as dept_name,bonus,grade from employees;

英文:

I have an Interactive grid.

select emp_name,dept_name,bonus,grade from employees;

Here dept_name is pop up lov with select query as :

select dept_name from departments;

Now all departments are named as:

01-Sales
02-Marketing
03-Accounts

and so on..

The requirement is that when the list is expanded in column it should show complete department names with the number prefixes.

But when the IG is displayed or loaded it should just show the first 2 digits, i.e. 01 or 02 or 03 instead of full name.

I tried using substr in the select query but it still displays the full name.

select emp_name,substr (dept_name,2) as dept_name,bonus,grade from employees;

答案1

得分: 0

根据我所了解,这个需求需要比你预期的更多的工作。

交互式网格的源查询:

select e.empno,
       e.ename, 
       e.deptno,
       e.job
from emp e

deptno 列应设置为一个弹出式 LOV,其源是一个共享组件值列表,如下所示:

select d.deptno as disp_val,
       d.dname  as dname,   
       d.deptno as ret_val
from dept d
order by d.deptno

这个查询中有3个值,而“普通”的 LOV 需要其中两个:显示值和返回值。Apex 允许你为支持此功能的项目创建附加列,而弹出式 LOV 就是其中之一。

设置 LOV 列映射如下:

  • 返回值:RET_VAL(它将显示部门编号,例如 10、20 等)
  • 显示值:DISP_VAL(它与 RET_VAL 完全相同,因为你只想要显示部门代码,而不是其名称)
  • 附加显示列(这里很关键!):它是一个穿梭项目 - 将所有项目移动到穿梭的右侧,即它应该包含 RET_VAL、DISP_VAL 和 DNAME

回到页面设计器

在交互式网格区域创建附加项目,让我们称之为 dummy,将其设置为隐藏,其源是。它将在下一步中使用。

导航到 deptno 列属性,并将附加输出属性设置为 DNAME:DUMMY,这意味着:从 LOV 中获取 dname 并将其值放入 dummy 列中(即不执行任何操作,因为这只是一个虚拟的隐藏列)。

运行页面。

最初,你只会看到部门代码(例如 10)。当你双击单元格并打开 LOV 时,你将看到部门代码其名称。选择任何值,保存,然后你将(再次)只看到代码。

正如我所说,这并不像听起来的那么简单。也许其他人知道更简单的方法。

英文:

As far as I can tell, that requirement requires a little bit more effort than you'd expect.

Interactive grid's source query:

select e.empno,
       e.ename, 
       e.deptno,
       e.job
from emp e

deptno column should be set as a Popup LOV whose source is a Shared component List of values which looks like this:

select d.deptno as disp_val,
       d.dname  as dname,   
       d.deptno as ret_val
from dept d
order by d.deptno

There are 3 values in this query, while "ordinary" LOVs require two of them: a display value and a return value. Apex lets you create additional columns for items that support that, and Popup LOVs are among them.

Set LOV column mapping as:

  • Return: RET_VAL (it'll display department number, e.g. 10, 20, ...)

  • Display: DISP_VAL (it is just the same as RET_VAL as you want to actually display only department code, not its name)

  • Additional display columns (that's crucial here!): it is a shuttle item - move all items to the right hand side of the shuttle, i.e. it should contain RET_VAL, DISP_VAL and DNAME

    Oracle Apex弹出式LOV应该显示完整的数字,但网格仅显示前4位数字。

Back to Page designer.

Create additional item in Interactive Grid region, let's call it dummy, make it hidden, its source is None. It'll be used in the next step.

Navigate to deptno column properties and set Additional outputs property to DNAME:DUMMY which means: take dname from the LOV and put its value into dummy column (i.e. don't do anything as this is just a dummy hidden column).

Oracle Apex弹出式LOV应该显示完整的数字,但网格仅显示前4位数字。

Run the page.

Initially, you see only department code (e.g. 10). When you double-click the cell and open LOV, you'll see both department code and its name. Select any value, Save, and you'll (again) see code only.

Oracle Apex弹出式LOV应该显示完整的数字,但网格仅显示前4位数字。


As I said, not as easy as it sounds. Perhaps someone else know simpler way to do that.

huangapple
  • 本文由 发表于 2023年7月3日 16:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76602994.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定