如何在Apex表格形式中识别当前行? [英] How to identify the current row in an Apex Tabular Form?

查看:71
本文介绍了如何在Apex表格形式中识别当前行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我编写了以下JavaScript,以确定用户当前使用的表格形式的哪一行.也就是说,他们点击了第4行上的选择列表.我需要该行号,然后才能在同一行上获取字段的正确值,然后我可以对其进行进一步的处理.

I have written the following JavaScript to ascertain which row of an tabular form the user is currently on. i.e. they have clicked a select list on row 4. I need the row number to then get the correct value of a field on this same row which I can then perform some further processing on.

此JavaScript的作用是获取触发项的ID,例如f02_0004这告诉我第4行第2列中的选择列表已被选择.因此,我的Javascript仅获取行信息,即0004,然后使用该信息来引用该行中的另一个字段,此刻,只需输出该值即可显示我具有正确的值.

What this JavaScript does is get the id of the triggering item, e.g. f02_0004 This tells me that the select list in column 2 of row 4 has been selected. So my Javascript gets just the row information i.e. 0004 and then uses that to reference another field in this row and at the moment just output the value to show I have the correct value.

<script language="JavaScript" type="text/javascript">
   function cascade(pThis){      
      var row = getTheCurrentRow(pThis.id);
      var nameAndRow = "f03_" + row;
      var costCentre = $x(nameAndRow).value;
      alert("the cost centre id is " + costCentre);

}
   // the triggerItem has the name fxx_yyyy where xx is the column number and 
   // yyyy is the row. This function just returns yyyyy    
   function getTheCurrentRow(triggerItem){   
      var theRow = triggerItem.slice(4);
      return theRow;         
}

尽管这行得通,但我不禁感到自己必须重新发明轮子,并且 要么,有内置的我可以使用,否则,也许没有一种更好"的方式?

Whilst this works I can't help feeling that I must be re-inventing the wheel and that either, there are built-in's that I can use or if not there maybe a "better" way?

如果需要,我会使用Apex 4.0

In case of need I'm using Apex 4.0

在此先感谢您提供的任何信息.

Thanks in advance for any you can provide.

推荐答案

好,您所描述的正是我自己通常要做的事情!

Well, what you have described is exactly what I typically do myself!

Apex 4.0中的一种替代方法是使用jQuery导航DOM,如下所示:

An alternative in Apex 4.0 would be to use jQuery to navigate the DOM something like this:

var costCentre = $(pThis).parents('tr').find('input[name="f03"]')[0].value;

我已经对此进行了测试,并且可以在我的测试表单中正常运行.

I have tested this and it works OK in my test form.

这篇关于如何在Apex表格形式中识别当前行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆