jquery 从网格查找服务器获取筛选器选项,而不是从服务器获取

ddhy6vgd  于 2023-10-17  发布在  jQuery
关注(0)|答案(1)|浏览(88)

我有一个配置了查找列的远程操作的devextreme数据网格。当我单击该列的筛选器行时,将从服务器调用填充选项,而不是显示查找表(对象数组)中的值。我不希望该调用生成这种昂贵的数据库分组查询,因为我的视图中已经有了这些值。我想要在this question中要求的完全相反的东西我如何才能实现我想要的行为?
我的dxdatagrid选项:

<script src="https://cdn3.devexpress.com/jslib/23.1.3/js/dx.all.js"></script>

{
                dataSource: DevExpress.data.AspNet.createStore({
                    key: 'id',
                    loadUrl: '/grid/data',
                    onBeforeSend(method, ajaxOptions) {
                        ajaxOptions.xhrFields = { withCredentials: true };
                    },
                }),
                remoteOperations: true,
                onEditorPreparing: function (e) {
                    if (e.parentType === "filterRow" && e.dataField === "channelId") {
                        e.editorOptions.onValueChanged = function (arg) {
                            filterEditor.option("dataSource", {
                                store: _statuses,
                                filter: ["channelId", "=", arg.value]
                            });
                            e.setValue(arg.value);
                        };
                    }
                },
                onEditorPrepared: function (e) {
                    if (e.parentType === "filterRow") {
                        if (e.dataField === "status") {
                            filterEditor = e.editorElement.dxSelectBox("instance");
                        }
                    }
                },
                columns: [{
                    type: "buttons",
                    width: 30,
                    buttons: [{
                        hint: 'Ver',
                        icon: 'eyeopen',
                        onClick(e) {
                            openModal(e.row);
                            e.event.preventDefault();
                        },
                    }]
                }, {
                    dataField: 'id',
                    caption: 'Codigo',
                }, {
                    dataField: 'created',
                    caption: 'Creada en',
                    dataType: 'date',
                    format: 'shortDateShortTime'
                }, {
                    dataField: 'channelId',
                    caption: 'Canal',
                    dataType: 'number',
                    setCellValue(rowData, value) {
                        rowData.channelId = value;
                        rowData.status = null;
                    },
                    lookup: {
                        dataSource: {
                            store: _channels
                        },
                        valueExpr: 'value',
                        displayExpr: 'text',
                    },
                }, {
                    dataField: 'status',
                    caption: 'Estado',
                    lookup: {
                        dataSource: function (options) {
                            return {
                                store: _statuses,
                                filter: options.data ? ['channelId', '=', options.data.channelId] : null
                            };
                        },
                        valueExpr: 'status',
                        displayExpr: 'description'
                    },
                    calculateDisplayValue: function (rowData) {
                        let found = _statuses.filter(s => s.channelId == rowData.channelId && s.status == rowData.status);
                        return found[0].description;
                    }
                }, {
                    dataField: 'statusGroup',
                    caption: 'Grupo',
                    lookup: {
                        dataSource: _statusGroups,
                        valueExpr: 'value',
                        displayExpr: 'text',
                    }
                }, {
                    dataField: 'contact_Name',
                    caption: 'Nombre',
                }
                ],
                filterRow: {
                    visible: true,
                },
                headerFilter: {
                    visible: false,
                },
                groupPanel: {
                    visible: true,
                },
                scrolling: {
                    mode: 'virtual',
                    rowRenderingMode: 'virtual',
                },
                paging: {
                    pageSize: 10,
                },
                pager: {
                    visible: true,
                    allowedPageSizes: [5, 10, 25],
                    showPageSizeSelector: true,
                    showInfo: true,
                    showNavigationButtons: true,
                }
            }
46qrfjad

46qrfjad1#

终于找到了关键是将选项“syncLookupFilterValues”设置为false。
syncLookupFilterValues

相关问题