Results 1 to 2 of 2

Thread: override and combo boxes

  1. #1

    Default override and combo boxes

    These are a few overrides that I needed when working with Ext.ux.grid.RowEditor in Ext 3.3.1

    Ext.override(Ext.ux.grid.RowEditor, {
         * This override fixes a bug and adds a feature to Ext.ux.RowEditor.
         * BUG - The bug was causing all date fields to be marked as dirty, even if the user left the value of the date field
         * unmodified in the row editor. The reason for this was that the editor was determining if a field had been modified
         * by invoking the field's getValue method and comparing it to the value in the grid's store. The problem with this is
         * that getValue returns a formatted date string which the editor was comparing a javascript date object obtained from
         * the grid's store. Changing the invocation of getValue to getRawValue fixed the problem.
         * FEATURE - Using combo boxes with the row editor was somewhat tedious because, while a combo has both a displayField
         * and a valueField, the row editor only updates a single field in the grid's store. In my case, I wanted the
         * displayField to be updated in the grid so that the user could visually confirm that the value had been changed but
         * I also wanted the valueField to be updated in the grid's store so invoking the store's save method would
         * correctly update the record on the server by id instead of by name. The alternative workaround seemed to be setting
         * up an ajax call to the server when the row editor's save button was clicked and then reloading the grid's store. I
         * would prefer to simply edit the grid and then save the grid's store. My solution, shown below, is to during the
         * editor's save operation join the combo's store against the grid's store using the valueField config property of the
         * combo as a common key. Therefore, as long as the identifier names in the grid's store and the combo's store match,
         * the identifier of the newly selected value, in the combo, will be silently updated in the grid's store. Saving the
         *  grid's store will then persist this change to the server.
        stopEditing : function(saveChanges){
            var si = this.storeDataIndex;
            this.editing = false;
            if(saveChanges === false || !this.isValid()){
                this.fireEvent('canceledit', this, saveChanges === false);
            var changes = {},
                r = this.record,
                hasChange = false,
                cm = this.grid.colModel,
                fields = this.items.items;
            for(var i = 0, len = cm.getColumnCount(); i < len; i++){
                var f = fields[i];
                    var dindex = cm.getDataIndex(i);
                        var oldValue =[dindex], newValue = this.postEditValue(f.getValue(), oldValue, r, dindex);
                        if(oldValue !== newValue){
                            if (f.getXType() === 'combo' && dindex !== 'id' && dindex !== f.initialConfig.valueField){
                                changes[f.initialConfig.valueField] = f.getValue();
                                changes[dindex] = f.getRawValue();
                                changes[dindex] = newValue;
                            hasChange = true;
            if(hasChange && this.fireEvent('validateedit', this, changes, r, this.rowIndex) !== false){
                Ext.iterate(changes, function(name, value){
                    r.set(name, value);
                this.fireEvent('afteredit', this, changes, r, this.rowIndex);
         * This override fixes one bug.
         * BUG - Invalid fields are not marked as invalid when the row editor is first opened, although they are correctly
         * marked as invalid then the row editor is subsequently opened. This override fixes this by invoking the
         * refreshFields method at the end of the row editor's init method.
        init: function(grid){
            this.grid = grid;
            this.ownerCt = grid;
            if(this.clicksToEdit === 2){
                grid.on('rowdblclick', this.onRowDblClick, this);
                grid.on('rowclick', this.onRowClick, this);
                    grid.on('rowdblclick', this.onRowDblClick, this);
            // stopEditing without saving when a record is removed from Store.
            grid.getStore().on('remove', function() {
                scope: this,
                keydown: this.onGridKey,
                columnresize: this.verifyLayout,
                columnmove: this.refreshFields,
                reconfigure: this.refreshFields,
                beforedestroy : this.beforedestroy,
                destroy : this.destroy,
                bodyscroll: {
                    buffer: 250,
                    fn: this.positionButtons
            grid.getColumnModel().on('hiddenchange', this.verifyLayout, this, {delay:1});
            grid.getView().on('refresh', this.stopEditing.createDelegate(this, []));
            this.addListener('beforeedit', function(){
            this.addListener('canceledit', function(){
            this.addListener('validateedit', function(){
            this.addListener('afteredit', function(){

  2. #2
    Sencha User
    Join Date
    Apr 2011


    lost code in stopEdition func

    PHP Code:
    if(hasChange && this.fireEvent('validateedit'thischangesrthis.rowIndex) !== false){
    Ext.iterate(changes, function(namevalue){
            } else {
    else {
    this.fireEvent('canceledit', this, false);

Similar Threads

  1. Ext.PagingToolbar with Filter Window using Ext.ux.grid.RowEditor (override)
    By jorgelive in forum Ext 3.x: User Extensions and Plugins
    Replies: 1
    Last Post: 16 Nov 2010, 4:58 AM
  2. Grid RowEditor; Communication between combo`s in a roweditor
    By Scorpie in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 26 Sep 2010, 10:28 PM
  3. Ext 3.2.1 - UX.RowEditor and Remote Combo
    By mask_hot in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 28 Apr 2010, 12:28 AM
  4. How to link two combo boxes which are inside Editor grid ?
    By srinivasp in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 17 Dec 2009, 2:37 AM
  5. Editable Combo Boxes in YUI-EXT .33
    By rojar in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 17 Jul 2007, 7:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts