【发布时间】:2018-08-09 13:14:41
【问题描述】:
我有一个剑道网格,每行有 6 个命令按钮,结构如下,但调用不同的函数。我正在寻找一种将数据传递给函数的方法,基于按下哪个按钮。现在,我在 java 端有 6 个函数,在 aspx 端有 6 个弹出窗口。我什至不确定它是否可以完成,但这只是很多重复的代码。下面是每个按钮的命令结构:
command: [{
name: "Edit",
title: "Alert Email",
width: "180px",
click: onDataBound75
}],
这是 6 个功能之一:
function onDataBound75(e) {
e.preventDefault();
$("#txtAlert").kendoEditor({
resizable: {
content: true,
toolbar: true,
encoded: false
}
});
var window = $("#emailAlert_popup").kendoWindow({
width: "600px",
visible: false,
modal: true,
actions: [
"Maximize",
"Close"
],
});
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var viewModelAlert75 = kendo.observable({
Alert75EmailSubject: dataItem.Alert75EmailSubject,
Alert75EmailBody: dataItem.Alert75EmailBody,
Alert75FromAddress: dataItem.Alert75FromAddress,
});
kendo.bind($("#emailAlert_popup"), viewModelAlert75);
window.data("kendoWindow").center().open();
};
这是 aspx 端的 6 个弹出窗口之一:
<div id="emailAlert_popup" class="TT_PopupWindow">
<div class="SearchParam">
<label class="control-label" for="txtAlert75EmailSubject" style="width:200px">Email Subject</label>
<input name="txtEmailSubject" id="txtAlert75EmailSubject" class="k-textbox" style="width:430px"
data-bind="value: Alert75EmailSubject" />
</div>
<div class="SearchParam">
<label class="control-label" for="txtAlert75EmailBody" style="width:200px">Email Body</label>
<textarea id="txtAlert" rows="10" cols="30" style="height:440px" aria-label="editor" data-bind="value: Alert75EmailBody"></textarea>
</div>
<div class="SearchParam">
<label class="control-label" for="txtAlert75FromAddress" style="width:200px">From Address</label>
<input name="txtFromAddress" id="txtAlert75FromAddress" class="k-textbox" style="width:430px"
data-bind="value: Alert75FromAddress"
/>
</div>
<div class="k-edit-buttons k-state-default">
<button type="button" id="btnAlert75EmailUpdate" data-role="button" class="k-button k-button-icontext k-primary k-grid-update" role="button" aria-disabled="false" tabindex="0" style="float:right"><span class="k-icon k-i-check"></span>Update</button>
<button type="button" id="btnAlert75Cancel" data-role="button" class="k-button k-button-icontext k-grid-cancel" role="button" aria-disabled="false" tabindex="1" style="float:right"><span class="k-icon k-i-cancel"></span>Cancel</button>
</div>
</div>
有没有办法让只有 1 个 javascript 函数将数据传递到 aspx 端,并且在 aspx 页面上只有 1 个弹出窗口?
【问题讨论】:
-
所有 6 个函数和弹出窗口都相等吗?各有什么变化?
-
@DontVoteMeDown 在数据源上,有 6 个独立的
EmailAddressEmailSubject和EmailBody,具体取决于按下的按钮。我需要将这 3 个数据字段发送到函数和弹出窗口。 -
对不起,我没有明白你的意思。
-
DataSource上有6个
emailAddress、6个emailBody和6个emailSubject。然后有 6 个按钮与emailAddress、emailBody和emailSubject的每组绑定。所以,假设第一个命令按钮被按下:emailAddress1、emailBody1和emailSubject1只需要传递给函数。其他命令按钮也是如此,但它们只是发送不同的emailAddress、emailBody和emailSubject。
标签: javascript asp.net kendo-ui kendo-grid