【问题标题】:Get Devexpress BootstrapGrid Selected Rows ServerSide获取 Devexpress Bootstrap Grid Selected Rows 服务器端
【发布时间】:2019-03-27 00:26:03
【问题描述】:

我使用 devexpress 引导网格视图,并获取选定的项目(因为我将复选框列添加到网格以选择行)我在选定更改时使用客户端事件。

现在我有一个问题,有时当用户选择行并尝试获取选定的行时,选定的行数组显示为空数组,而它有数据。

我们可以从服务器端获取这些选定的行吗? 在客户端,除了 Grid selected 事件之外,我们可以吗?

<dx:BootstrapGridView ID="dgvData" runat="server" KeyFieldName="Id" Width="100%" 
    ClientInstanceName="dgvData" ClientSideEvents-SelectionChanged="OnDataGridSelectionChanged"
    OnDataBinding="dgvData_DataBinding" EnableRowsCache="false">
    <SettingsAdaptivity AdaptivityMode="HideDataCells" AllowOnlyOneAdaptiveDetailExpanded="true" />
    <SettingsSearchPanel Visible="false" ShowApplyButton="true" />
    <Settings ShowGroupPanel="false" ShowHeaderFilterButton="true" ShowFilterRow="true" />
    <Columns>
        <dx:BootstrapGridViewCommandColumn ShowSelectCheckbox="True" SelectAllCheckboxMode="AllPages" />
        ...
    </Columns>
    <SettingsPager PageSize="1000" PageSizeItemSettings-Visible="false" Visible="false"></SettingsPager>
    <SettingsBootstrap Striped="true" />
</dx:BootstrapGridView>

<script type="text/javascript">
function OnDataGridSelectionChanged() {
    dgvData.GetSelectedFieldValues('Id', OnDataGridSelectionComplete);
}

var DataKeys = [];
function OnDataGridSelectionComplete(values) {
    DataKeys = values;
}
</script>

【问题讨论】:

  • 您是否已经尝试使用GetRowValues 方法并以dgvData.KeyFieldName 作为其参数? BootstrapGridViewASPxGridView 有许多相似的行为,因此您可以使用从后者到前者的相同方法。

标签: javascript c# asp.net devexpress bootstrap-4


【解决方案1】:

我建议你阅读文档:Bootstrap GridView - Selection

尝试设置客户端事件以获取选择,如下所示:

<ClientSideEvents Init="onSelectionGridViewAction" SelectionChanged="onSelectionGridViewAction" EndCallback="onSelectionGridViewAction" />

//js

function onSelectionGridViewAction(s, e) {
    $("#selectionLabel").html("Total rows selected: " + s.GetSelectedRowCount());
}

参考:BootstrapGridView - How to retrieve values from a Bootstrap GridView in code-behind

要在服务器端获取 BootstrapGridView 行值,可以使用 GetRowValues 方法。请参阅GetRowValues 文章,其中 包含说明如何使用此方法的示例项目。 虽然本文针对 ASPxGridView,但相同的解决方案是 BootstrapGridView 也是如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 2018-04-30
    • 2020-01-20
    • 2017-03-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    相关资源
    最近更新 更多