You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否禁用JavaScript ag-Grid的水平填充柄?及最优实现方案

Restricting ag-Grid Fill Handle to Vertical Only Directions

Absolutely, you’re on the right path here! The fillOperation callback is exactly the tool you need to lock the fill handle to only vertical (up/down) directions—even if the official docs don’t explicitly call out this use case.

Here’s a straightforward implementation to block horizontal fills while keeping vertical functionality intact:

const gridOptions = {
  // ... your existing grid configuration
  fillOperation: function(params) {
    // Allow only vertical fill directions
    if (params.direction === 'up' || params.direction === 'down') {
      // Use ag-Grid's default fill logic for vertical actions
      return { operation: 'default' };
    } else {
      // Return null to cancel horizontal fill attempts
      return null;
    }
  }
};

Breakdown of how this works:

  • The fillOperation callback gets a params object that includes the direction of the attempted fill (valid values: 'up', 'down', 'left', 'right').
  • When you return null for horizontal directions (left/right), ag-Grid will entirely ignore the fill request, stopping any horizontal data propagation.
  • For vertical directions, returning { operation: 'default' } lets the grid use its standard fill behavior—whether that’s copying static values or incrementing sequences like dates/numbers.

This setup will eliminate the unwanted horizontal fill behavior from the examples, ensuring the fill handle only operates up and down as you expect.

内容的提问来源于stack exchange,提问作者Javier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 15:47:43