All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.extjs.gxt.ui.client.widget.grid.EditorGrid Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Sencha GXT 2.3.1 - Sencha for GWT
 * Copyright(c) 2007-2013, Sencha, Inc.
 * [email protected]
 * 
 * http://www.sencha.com/products/gxt/license/
 */
 package com.extjs.gxt.ui.client.widget.grid;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.store.ListStore;
import com.google.gwt.user.client.Element;

/**
 * Adds editing capabilities to Grid.
 * 
 * 
*
Events:
* *
BeforeEdit : GridEvent(grid, record, property, value, rowIndex, * colIndex)
*
Fires before cell editing is triggered. Listeners can cancel the action * by calling {@link BaseEvent#setCancelled(boolean)}.
*
    *
  • grid : this
  • *
  • record : the record being edited
  • *
  • property : the property being edited
  • *
  • value : the value being edited
  • *
  • rowIndex : the current row
  • *
  • colIndex : the current column
  • *
*
* *
AfterEdit : GridEvent(grid, record, property, value, startValue, * rowIndex, colIndex)
*
Fires after a cell is edited.
*
    *
  • grid : this
  • *
  • record : the record being edited
  • *
  • property : the property being edited
  • *
  • value : the value being set
  • *
  • startValue : the value before the edit
  • *
  • rowIndex : the current row
  • *
  • colIndex : the current column
  • *
*
* *
ValidateEdit : GridEvent(grid, record, property, value, * startValue, rowIndex, colIndex)
*
Fires right before the record is updated. Listeners can cancel the * action by calling {@link BaseEvent#setCancelled(boolean)}.
*
    *
  • grid : this
  • *
  • record : the record being edited
  • *
  • property : the property being edited
  • *
  • value : the value being set
  • *
  • startValue : the value before the edit
  • *
  • rowIndex : the current row
  • *
  • colIndex : the current column
  • *
*
* *
*/ public class EditorGrid extends Grid { /** * ClicksToEdit enumeration. */ public enum ClicksToEdit { /** * Editing start with one click. */ ONE, /** * Editing starts with double click. */ TWO; } /** * Creates a new editor grid. * * @param store the store * @param cm the column model */ @SuppressWarnings({"unchecked", "rawtypes"}) public EditorGrid(ListStore store, ColumnModel cm) { super(store, cm); setSelectionModel(new CellSelectionModel()); setTrackMouseOver(false); editSupport = getEditSupport(); editSupport.bind(this); } /** * Returns the active editor. * * @return the active editor */ public CellEditor getActiveEditor() { return editSupport.getActiveEditor(); } /** * Returns the clicks to edit. * * @return the clicks to edit */ public ClicksToEdit getClicksToEdit() { return editSupport.getClicksToEdit(); } /** * Returns true if editing is active. * * @return the editing state */ public boolean isEditing() { return editSupport.isEditing(); } @Override public void reconfigure(ListStore store, ColumnModel cm) { super.reconfigure(store, cm); editSupport.bind(this); } /** * Sets the number of clicks to edit (defaults to ONE). * * @param clicksToEdit the clicks to edit */ public void setClicksToEdit(ClicksToEdit clicksToEdit) { editSupport.setClicksToEdit(clicksToEdit); } /** * Starts editing the specified for the specified row/column. * * @param row the row index * @param col the column index */ public void startEditing(final int row, final int col) { editSupport.startEditing(row, col); } /** * Stops any active editing. */ public void stopEditing() { editSupport.stopEditing(); } /** * Stops any active editing. * * @param cancel true to cancel, false to complete */ public void stopEditing(boolean cancel) { editSupport.stopEditing(cancel); } @Override protected void onDoubleClick(GridEvent e) { if (editSupport.onDoubleClick(e)) { return; } super.onDoubleClick(e); } @Override protected void onRender(Element target, int index) { super.onRender(target, index); editSupport.doRender(); setAriaState("aria-readonly", "false"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy