gpt4 book ai didi

Grails 中的 Javascript 表格单击功能

转载 作者:行者123 更新时间:2023-12-03 12:03:53 25 4
gpt4 key购买 nike

如果我有下表:

enter image description here

我希望在任意行上单击红点时调用一个 Controller 函数 A,但在单击任意行上的编辑图标时调用函数 B。

使用此 JavaScript 单击任意行上的红点时,我已成功调用一个函数:

var myTable = document.getElementById('indivTble');

if (myTable != null) {
rows = myTable.getElementsByTagName('tr');
var selectedUniqueId, selectedSecondaryId;

for (var i=1,len=rows.length; i<len; i++) {
rows[i].onclick = function() {
selectedUniqueId = this.cells[2].innerHTML;
selectedSecondaryId = parseInt(this.cells[3].innerHTML);
<g:remoteFunction controller="customer"
action="editRecord"
update="flagsSummary"
params="{uniqueId: selectedUniqueId, secondaryId: selectedSecondaryId}"/>

但我无法将第二个功能绑定(bind)到编辑图标,即:

<g:remoteFunction controller="customer" 
action="displayRecordDetails"
update="flagsSummary"
params="{uniqueId: selectedUniqueId, secondaryId: selectedSecondaryId}"/>

如果有任何帮助,我将不胜感激。

最佳答案

试试这个:

for (var i=1,len=rows.length; i<len; i++)   {

rows[i].cells[0].onclick = function() {
selectedUniqueId = this.parentNode.cells[2].innerHTML;
selectedSecondaryId = parseInt(this.parentNode.cells[3].innerHTML);
<g:remoteFunction controller="customer"
action="editRecord"
update="flagsSummary"
params="{uniqueId: selectedUniqueId, secondaryId: selectedSecondaryId}"/>
}
}
for (var i=1,len=rows.length; i<len; i++) {

rows[i].cells[1].onclick = function() {
selectedUniqueId = this.parentNode.cells[2].innerHTML;
selectedSecondaryId = parseInt(this.parentNode.cells[3].innerHTML);
<g:remoteFunction controller="customer"
action="displayRecordDetails"
update="flagsSummary"
params="{uniqueId: selectedUniqueId, secondaryId: selectedSecondaryId}"/>
}
}

关于Grails 中的 Javascript 表格单击功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25273085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com