---
title: "Ext.grid.RowEditor"
description: "xtype 为 roweditor 的 Ext JS 原生组件参考。"
---

> Documentation Index
> Fetch the complete documentation index at: https://ag.879818327.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Ext.grid.RowEditor

源码定义：`ext-all-debug.js:117474`。分类：数据视图、表格与树。

## 创建示例

```javascript
var component = Ext.create("Ext.grid.RowEditor", {
  xtype: "roweditor",
  border: false,
  buttonUI: 'default',
  cancelBtnText: 'Cancel',
  dirtyText: 'You need to commit or cancel your changes',
  renderTo: Ext.getBody()
});
```

## 属性

| 属性 | 类型 | 默认值 | 说明 | 配置示例 |
| --- | --- | --- | --- | --- |
| `border` | `Boolean` | `false` | 控制是否显示组件边框。 | `border: false` |
| `buttonUI` | `String` | `'default'` | 配置组件的 `buttonUI` 选项。 | `buttonUI: 'default'` |
| `cancelBtnText` | `String` | `'Cancel'` | 配置组件的 `cancelBtnText` 选项。 | `cancelBtnText: 'Cancel'` |
| `dirtyText` | `String` | `'You need to commit or cancel your changes'` | 配置组件的 `dirtyText` 选项。 | `dirtyText: 'You need to commit or cancel your changes'` |
| `errorCls` | `Mixed` | `Ext.baseCSSPrefix + 'grid-row-editor-errors-i...` | 配置 `errorCls` 对应的 CSS 类名。 | `errorCls: Ext.baseCSSPrefix + 'grid-row-editor-errors-i...` |
| `errorsText` | `String` | `'Errors'` | 配置组件的 `errorsText` 选项。 | `errorsText: 'Errors'` |
| `hideMode` | `String` | `'offsets'` | 配置组件的 `hideMode` 选项。 | `hideMode: 'offsets'` |
| `lastScrollLeft` | `Number` | `0` | 配置组件的 `lastScrollLeft` 选项。 | `lastScrollLeft: 0` |
| `lastScrollTop` | `Number` | `0` | 配置组件的 `lastScrollTop` 选项。 | `lastScrollTop: 0` |
| `saveBtnText` | `String` | `'Update'` | 配置组件的 `saveBtnText` 选项。 | `saveBtnText: 'Update'` |

## 方法

| 方法 | 参数 | 说明 | 调用示例 |
| --- | --- | --- | --- |
| `initComponent` | `` | 初始化组件及其子项。 执行时会保留父类默认行为、更新 `cls`、`layout` 状态。源码涉及 `callParent()`、`addFieldsForColumn()`、`insertColumnEditor()`、`mon()`。 | `component.initComponent()` |
| `onGridResize` | `` | 处理 `gridResize` 回调。源码涉及 `getClientWidth()`、`getFloatingButtons()`、`setLocalX()`、`setWidth()`。 | `component.onGridResize()` |
| `syncAllFieldWidths` | `` | 同步 `allFieldWidths`。源码涉及 `query()`、`onColumnShow()`。 | `component.syncAllFieldWidths()` |
| `syncFieldWidth` | `column` | 同步 `fieldWidth`。 | `component.syncFieldWidth(...)` |
| `onValidityChange` | `form, valid` | 处理 `validityChange` 回调。 执行时会更新 `isValid` 状态。源码涉及 `isVisible()`、`updateButton()`。 | `component.onValidityChange(...)` |
| `updateButton` | `valid` | 更新 `button`。 执行时会更新 `updateButtonDisabled` 状态。 | `component.updateButton(...)` |
| `afterRender` | `` | 生成 `after` 的渲染结果。 执行时会保留父类默认行为、同步关联状态、更新 `scrollingView`、`scrollingViewEl` 状态。源码涉及 `callParent()`、`mon()`、`initKeyNav()`、`syncAllFieldWidths()`。 | `component.afterRender()` |
| `initKeyNav` | `` | 初始化 `keyNav`。 执行时会更新 `keyNav` 状态。 | `component.initKeyNav()` |
| `onBeforeViewRefresh` | `view` | 处理 `beforeViewRefresh` 回调。 | `component.onBeforeViewRefresh(...)` |
| `onViewRefresh` | `view` | 处理 `viewRefresh` 回调。源码涉及 `reposition()`。 | `component.onViewRefresh(...)` |
| `onViewItemRemove` | `record, index` | 处理 `viewItemRemove` 回调。 | `component.onViewItemRemove(...)` |
| `onViewScroll` | `` | 处理 `viewScroll` 回调。 执行时会同步关联状态、更新 `lastScrollTop`、`lastScrollLeft` 状态。源码涉及 `isVisible()`、`reposition()`、`repositionTip()`、`syncEditorClip()`。 | `component.onViewScroll()` |
| `syncFieldsHorizontalScroll` | `` | 同步 `fieldsHorizontalScroll`。 | `component.syncFieldsHorizontalScroll()` |
| `onFieldContainerScroll` | `` | 处理 `fieldContainerScroll` 回调。 | `component.onFieldContainerScroll()` |
| `onColumnResize` | `column, width` | 处理 `columnResize` 回调。 执行时会同步关联状态。源码涉及 `onGridResize()`、`onViewScroll()`、`syncFieldWidth()`、`repositionIfVisible()`。 | `component.onColumnResize(...)` |
| `onColumnHide` | `column` | 处理 `columnHide` 回调。源码涉及 `repositionIfVisible()`。 | `component.onColumnHide(...)` |
| `onColumnShow` | `column` | 处理 `columnShow` 回调。 执行时会同步关联状态。源码涉及 `syncFieldWidth()`、`repositionIfVisible()`。 | `component.onColumnShow(...)` |
| `onColumnMove` | `column, fromIdx, toIdx` | 处理 `columnMove` 回调。源码涉及 `setColumnEditor()`。 | `component.onColumnMove(...)` |
| `setColumnEditor` | `column, idx, fieldContainer` | 设置 `columnEditor`。源码涉及 `addFieldsForColumn()`。 | `component.setColumnEditor(...)` |
| `onColumnAdd` | `column` | 处理 `columnAdd` 回调。 执行时会更新 `preventReposition` 状态。源码涉及 `addFieldsForColumn()`、`insertColumnEditor()`。 | `component.onColumnAdd(...)` |
| `insertColumnEditor` | `column` | 处理 `insertColumnEditor` 操作。 执行时会更新 `needsSyncFieldWidths` 状态。 | `component.insertColumnEditor(...)` |
| `destroyColumnEditor` | `column` | 销毁 `columnEditor`。源码涉及 `removeColumnEditor()`。 | `component.destroyColumnEditor(...)` |
| `getFloatingButtons` | `` | 读取并返回 `floatingButtons`。 执行时会更新 `floatingButtons` 状态。 | `component.getFloatingButtons()` |
| `repositionIfVisible` | `c` | 处理 `repositionIfVisible` 操作。源码涉及 `isVisible()`、`reposition()`。 | `component.repositionIfVisible(...)` |
| `getRefOwner` | `` | 读取并返回 `refOwner`。 | `component.getRefOwner()` |
| `getRefItems` | `deep` | 读取并返回 `refItems`。 执行时会保留父类默认行为。源码涉及 `callParent()`、`getFloatingButtons()`。 | `component.getRefItems(...)` |
| `reposition` | `animateConfig, fromScrollHandler` | 处理 `reposition` 操作。 执行时会同步关联状态。源码涉及 `syncButtonPosition()`、`getScrollDelta()`、`calculateLocalRowTop()`、`calculateEditorTop()`。 | `component.reposition(...)` |
| `getScrollDelta` | `` | 读取并返回 `scrollDelta`。源码涉及 `getHeight()`。 | `component.getScrollDelta()` |
| `calculateLocalRowTop` | `row` | 计算 `localRowTop`。 | `component.calculateLocalRowTop(...)` |
| `calculateEditorTop` | `rowTop` | 计算 `editorTop`。 | `component.calculateEditorTop(...)` |
| `getClientWidth` | `` | 读取并返回 `clientWidth`。 | `component.getClientWidth()` |
| `getEditor` | `fieldInfo` | 读取并返回 `editor`。源码涉及 `query()`。 | `component.getEditor(...)` |
| `addFieldsForColumn` | `column, initial` | 添加 `fieldsForColumn`。源码涉及 `getDefaultFieldCfg()`、`isVisible()`、`renderColumnData()`、`onColumnHide()`。 | `component.addFieldsForColumn(...)` |
| `getDefaultFieldCfg` | `` | 读取并返回 `defaultFieldCfg`。 | `component.getDefaultFieldCfg()` |
| `loadRecord` | `record` | 加载 `record`。源码涉及 `getForm()`、`hideToolTip()`、`showToolTip()`、`updateButton()`。 | `component.loadRecord(...)` |
| `renderColumnData` | `field, record, activeColumn` | 渲染 `columnData`。 | `component.renderColumnData(...)` |
| `beforeEdit` | `` | 在 `edit` 前执行预处理。源码涉及 `isVisible()`、`isDirty()`、`getScrollDelta()`、`showToolTip()`。 | `component.beforeEdit()` |
| `startEdit` | `record, columnHeader` | 开始 `edit`。 执行时会同步关联状态、更新 `context`、`width` 状态。源码涉及 `getClientWidth()`、`render()`、`getFloatingButtons()`、`onViewScroll()`。 | `component.startEdit(...)` |
| `syncButtonPosition` | `scrollDelta` | 同步 `buttonPosition`。 执行时会更新 `_buttonsOnTop` 状态。源码涉及 `getFloatingButtons()`、`getScrollDelta()`。 | `component.syncButtonPosition(...)` |
| `syncEditorClip` | `` | 同步 `editorClip`。 执行时会更新 `isOverflowing` 状态。源码涉及 `getScrollDelta()`、`clipBottom()`、`getHeight()`、`clipTop()`。 | `component.syncEditorClip()` |
| `focusContextCell` | `` | 将焦点移动到 `contextCell`。源码涉及 `getEditor()`。 | `component.focusContextCell()` |
| `cancelEdit` | `` | 取消 `edit`。源码涉及 `getForm()`、`hide()`。 | `component.cancelEdit()` |
| `completeEdit` | `` | 完成 `edit`。源码涉及 `getForm()`、`hide()`。 | `component.completeEdit()` |
| `onShow` | `` | 处理 `show` 回调。 执行时会保留父类默认行为、同步关联状态。源码涉及 `callParent()`、`suspendLayouts()`、`syncAllFieldWidths()`、`resumeLayouts()`。 | `component.onShow()` |
| `onHide` | `` | 处理 `hide` 回调。 执行时会保留父类默认行为、更新 `context` 状态。源码涉及 `callParent()`、`hideToolTip()`。 | `component.onHide()` |
| `isDirty` | `` | 判断 `dirty` 状态。源码涉及 `getForm()`。 | `component.isDirty()` |
| `getToolTip` | `` | 读取并返回 `toolTip`。 执行时会更新 `tooltip` 状态。 | `component.getToolTip()` |
| `hideToolTip` | `` | 隐藏 `toolTip`。 执行时会更新 `hiddenTip` 状态。源码涉及 `getToolTip()`。 | `component.hideToolTip()` |
| `showToolTip` | `` | 显示 `toolTip`。源码涉及 `getToolTip()`、`getErrors()`、`repositionTip()`。 | `component.showToolTip()` |
| `repositionTip` | `` | 处理 `repositionTip` 操作。 执行时会更新 `hiddenTip` 状态。源码涉及 `getToolTip()`。 | `component.repositionTip()` |
| `getErrors` | `` | 读取并返回 `errors`。源码涉及 `query()`、`isDirty()`、`createErrorListItem()`。 | `component.getErrors()` |
| `createErrorListItem` | `e` | 创建 `errorListItem`。 | `component.createErrorListItem(...)` |
| `beforeDestroy` | `` | 在 `destroy` 前执行预处理。 执行时会保留父类默认行为。源码涉及 `callParent()`。 | `component.beforeDestroy()` |
| `clipBottom` | `value` | 处理 `clipBottom` 操作。 | `component.clipBottom(...)` |
| `clipTop` | `value` | 处理 `clipTop` 操作。 | `component.clipTop(...)` |
| `clearClip` | `el` | 清空 `clip`。 | `component.clearClip(...)` |

## 事件

源码中未找到该组件自身注册的事件；可监听继承事件。

Source: https://ag.879818327.xyz/ext/data/grid-roweditor/index.mdx
