gpt4 book ai didi

javascript - ShieldUI 网格 : how to get the row where the doubleclick is fired

转载 作者:行者123 更新时间:2023-11-30 06:18:42 25 4
gpt4 key购买 nike

我有一个搜索掩码,我希望当双击一行时,返回所选行的代码。我正在使用 shieldui 的 shieldGrid。如何获取选中的行?

我尝试检索选定的行,但它仍然是空的。

@using TheBetterWayStoreHandler.Resources
@model TheBetterWayStoreHandler.Models.CustomerGroupModel

@{
ViewBag.Title = "Ricerca Clienti";
Layout = "~/Views/Shared/_PagesLayout.cshtml";
}

<form id="searchCustomerForm" action='@Html.Raw(@Url.Action("SearchSelection", "Customer"))?selectedCustomer=' + selectedCustomer.value method="post">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top" style="background-color: #e3f2fd;">
<a class="navbar-brand" href="@Url.Action("Index", "Dashboard")">The Better Way - @ViewBag.Title</a>
<ul class="navbar-nav">
<li class="nav-item">
<button type="submit" class="btn btn-outline-success" data-toggle="tooltip" title="Salva" data-placement="bottom" value="Input Button">
<span class="fa fa-hdd fa-lg" aria-hidden="true"></span>
</button>
</li>
</ul>
</nav>
<div class="container-fluid body-content" style="height: 100%">
<input id="selectedCustomer" name="selectedCustomer" type="hidden" value="">
<div id="customerSearchGrid"></div>
</div>
</form>

<script>
var selectedCustomerVar = "";
jQuery(function ($) {
$("#customerSearchGrid").shieldGrid({
dataSource: {
remote: {
read: "@Session["ApiPath"]" + "GetCustomerSearch?searchString=" + "@Session["SearchString"]",
}
},
rowHover: true,
columns: [
{ field: "CustomerCode", width: "80px", title: "@Resources.Tb_CustomerCode", type: String },
{ field: "CustomerDescription", title: "@Resources.Tb_CustomerDescription", type: String }
],
sorting: {
multiple: true
},
scrolling: true,
height: "700px",
selection: {
type: "row",
multiple: false,
toggle: true
},
editing: {
enabled: false
},
events: {
selectionChanged: function (e) {
var selected = e.target.contentTable.find(".sui-selected");
if (selected.length > 0) {
selectedCustomer.value = selected[0].cells[0].textContent;
}
else {
selectedCustomer.value = "";
}
},
ondblClickRow: function(rowId) {
var rowData = jQuery(this).getRowData(rowId);
var customerCode = rowData['CustomerCode'];
location.href = '@Url.Action("SearchSelection", "Customer")?selectedCustomer=' + customerCode;
}
}
});
});

$("#customerSearchGrid").dblclick(function () {
var sel = $("#customerSearchGrid").swidget().selectedRowIndices();
alert(sel);
window.searchCustomerForm.submit();
});

selectedCustomer 为空,sel 变量也为空...

谢谢。

最佳答案

可能在处理选择之前引发了 dblclick 事件...

您可以尝试使用 selectionChanged处理选择更改的事件。

关于javascript - ShieldUI 网格 : how to get the row where the doubleclick is fired,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54655833/

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