Javascript 屏蔽网格:如何获取触发双击的行

Javascript 屏蔽网格:如何获取触发双击的行,javascript,datagridview,grid,shieldui,Javascript,Datagridview,Grid,Shieldui,我有一个搜索掩码,我希望当双击一行时,返回所选行的代码。 我正在使用shieldui的shieldGrid。 如何获取所选行 我尝试检索所选行,但它仍然为空 @using TheBetterWayStoreHandler.Resources @model TheBetterWayStoreHandler.Models.CustomerGroupModel @{ ViewBag.Title = "Ricerca Clienti"; Layout = "~/Views/Shared

我有一个搜索掩码,我希望当双击一行时,返回所选行的代码。 我正在使用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();
});
@使用BetterWayStoreHandler.Resources
@为BetterWayStoreHandler.Models.CustomerGroup模型建模
@{
ViewBag.Title=“Ricerca Clienti”;
Layout=“~/Views/Shared/_PagesLayout.cshtml”;
}
var selectedCustomerVar=“”; jQuery(函数($){ $(“#customerSearchGrid”).shieldGrid({ 数据源:{ 远程:{ 阅读:“@Session[“ApiPath”]”+“GetCustomerSearch?searchString=“+”@Session[“searchString”]”, } }, rowHover:是的, 栏目:[ {字段:“CustomerCode”,宽度:“80px”,标题:“@Resources.Tb_CustomerCode”,类型:String}, {字段:“CustomerDescription”,标题:“@Resources.Tb_CustomerDescription”,类型:String} ], 分类:{ 多重:对 }, 滚动:对, 高度:“700px”, 选择:{ 键入:“行”, 多重:假, 切换:真 }, 编辑:{ 已启用:false }, 活动:{ 选择更改:功能(e){ var selected=e.target.contentTable.find(“.sui selected”); 如果(已选定。长度>0){ selectedCustomer.value=所选[0]。单元格[0]。文本内容; } 否则{ selectedCustomer.value=“”; } }, ondblClickRow:函数(rowId){ var rowData=jQuery(this).getRowData(rowId); var customerCode=rowData['customerCode']; location.href='@Url.Action(“SearchSelection”,“Customer”)?selectedCustomer='+customerCode; } } }); }); $(“#customerSearchGrid”).dblclick(函数(){ var sel=$(“#customerSearchGrid”).swidget().selectedRowIndexes(); 警报(sel); window.searchCustomPerform.submit(); });
selectedCustomer为空,sel变量也为空


谢谢。

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

您可以尝试使用事件来处理选择更改