1. #1
    Ext User
    Join Date
    Aug 2010
    Posts
    4
    Vote Rating
    0
    Chupa is on a distinguished road

      0  

    Default Saving empty record when using RowEditor

    Saving empty record when using RowEditor


    Hello.

    I'm using RowEditor with my grid.
    I have a RESTful datasource. When i click a new button, roweditor appears and try to save empty record.
    I see an ajax request in firebug. I don't want to save empty record. I want to save only when save button pressed.

    What i am doing wrong?

    Code:
    HTML Code:
    Ext.namespace('SMC.components');
    
    SMC.components.ResourceGrid = Ext.extend(Ext.grid.GridPanel, {
        initComponent: function() {
            var self = this;
            var editor = new Ext.ux.grid.RowEditor({});
    
            Ext.applyIf(this, {
                iconCls: 'icon-grid',
                frame: true,
                autoScroll: true,
                width: 800,
                height: 300,
                plugins: [editor],
                tbar: [
                    {
                        text: 'New',
                        iconCls: 'silk-add',
                        handler: function() {
                            this.addRecord.call(this);
                        },
                        scope: this
                    },
                    '-',
                    {
                        text: 'Delete',
                        iconCls: 'silk-delete',
                        handler: function() {
                            this.deleteRecord.call(this);
                        },
                        scope: this
                    }
                ],
                viewConfig: {
                    forceFit: true
                },
                deleteRecord: function() {
                    var rec = this.getSelectionModel().getSelected();
                    if (!rec) {
                        return false;
                    }
                    this.store.remove(rec);
                },
                addRecord: function() {
                    var Dummy = Ext.data.Record.create(this.model.getFields());
    
                    editor.stopEditing();
                    this.store.insert(0, new Dummy({}));
                    this.getView().refresh();
                    editor.startEditing(0);
                }
            });
    
            SMC.components.ResourceGrid.superclass.initComponent.call(this);
        }
    });

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Configure your record so it returns isValid() == false for records that shouldn't be saved yet (you could do this by configuring one or more fields with allowBlank:false).

  3. #3
    Ext User
    Join Date
    Aug 2010
    Posts
    4
    Vote Rating
    0
    Chupa is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    Configure your record so it returns isValid() == false for records that shouldn't be saved yet (you could do this by configuring one or more fields with allowBlank:false).
    Thanks a lot. It works.

Similar Threads

  1. Help with updating/saving a record GRID Editor
    By brink668 in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 9 May 2010, 6:10 PM
  2. [UNKNOWN][3.??] roweditor's record object empty
    By realjax in forum Ext 3.x: Bugs
    Replies: 3
    Last Post: 23 Dec 2009, 5:20 AM
  3. Inserting a record in a store and saving the data in the database
    By cadudecastroalves in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 11 Feb 2008, 10:59 AM

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar