1. #1
    Sencha User ekolesmanasijabat's Avatar
    Join Date
    Dec 2012
    Posts
    6
    Vote Rating
    0
    ekolesmanasijabat is on a distinguished road

      0  

    Default Answered - Grid Row Editing Not Working

    Answered - Grid Row Editing Not Working


    Hi,
    I have implemented RowEditing plugins in grid. i have button "Add Employee" in tbar grid. But nothing happen when i click the button. What should i do?

    Here is my code.

    DataPoliklinikRuangan.js => Store
    Code:
    Ext.define('ONC.store.DataPoliklinikRuanganStore', {
        extend: 'Ext.data.Store',
        model: 'ONC.model.DataPoliklinikRuanganModel',
        
        remoteStore: true,
        pageSize: 2,
        autoLoad: { start: 0, limit: 2 },
        
        proxy: {
            type: 'ajax',
            api: {
                create: 'application/controllers/dataPRCreate.php',
                read: 'application/controllers/dataPRList.php',
                update: 'application/controllers/dataPRUpdate.php',
                destroy: 'application/controllers/dataPRDelete.php'
            },
            reader: {
                type: 'json',
                root: 'results',
                totalProperty: 'total',
                successProperty: 'success'
            }
        }
    });


    DataPoliklinikRuanganModel.js => Model
    Code:
    Ext.define('ONC.model.DataPoliklinikRuanganModel', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
        fields: ['id', 'kode', 'tipe', 'deskripsi', 'ruang', 'jlhbed', 'tarifperhari', 'telp', 'penanggungjawab']
    });


    DataPoliklinikRuangan.js => View
    Code:
    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
        clicksToMoveEditor: 1,
        autoCancel: false
    });
    
    
    Ext.Loader.setPath('Ext.ux', 'extjs/src/ux');
    Ext.define('ONC.view.dataklinik.DataPoliklinikRuangan', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.data-poliklinik-ruangan-panel',
        
        requires: [ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*', 'Ext.form.*', 'Ext.ux.CheckColumn' ],
        
        store: 'DataPoliklinikRuanganStore',
        stripeRows: true,
        height: 400,
        
        columns: [
            { header: 'Kode', dataIndex: 'kode', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Tipe', dataIndex: 'tipe', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Deskripsi', dataIndex: 'deskripsi', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Ruang', dataIndex: 'ruang', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Jumlah Bed', dataIndex: 'jlhbed', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Tarif/Hari', dataIndex: 'tarifperhari', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Telp', dataIndex: 'telp', flex: 1, editor: { allowBlank: false } }, 
            { header: 'Penanggung Jawab', dataIndex: 'penanggungjawab', flex: 1, editor: { allowBlank: false } }
        ],
        
        tbar: [
            {
                text: 'Add Employee',
                iconCls: 'employee-add',
                handler: function() {
                    rowEditing.cancelEdit();
    
    
                    var r = Ext.create('ONC.model.DataPoliklinikRuanganModel', {
                        id: ' ', 
                        kode: ' ',
                        tipe: ' ',
                        deskripsi: ' ',
                        ruang: ' ',
                        jlhbed: ' ',
                        tarifperhari: ' ',
                        telp: ' ',
                        penanggungjawab: ' '
                    });
                    
                    console.log(r);
    
    
                    store.insert(0, r);
                    rowEditing.startEdit(0, 0);
                }
            }, {
                itemId: 'removeEmployee',
                text: 'Remove Employee',
                iconCls: 'employee-remove',
                handler: function() {
                    var sm = grid.getSelectionModel();
                    rowEditing.cancelEdit();
                    store.remove(sm.getSelection());
                    if (store.getCount() > 0) {
                        sm.select(0);
                    }
                },
                disabled: true
            }
        ],
        plugins: [rowEditing],
        listeners: {
            'selectionchange': function(view, records) {
                grid.down('#removeEmployee').setDisabled(!records.length);
            }
        }
    });
    Last edited by ekolesmanasijabat; 2 Jan 2013 at 8:48 PM. Reason: Answered
    Eko Lesmana Sijabat

    #Our Creator, Science, and Us#
    w: http://www.triwahana.com/
    e: eko@triwahana.com

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    Are you receiving any errors? Is the new record successfully getting added to your store?

    I imagine the record isn't getting inserted into the store since the "store" variable in your handler doesn't seem to be pointing to anything. Try:

    PHP Code:
    {   
        
    text'Add Employee',   
        
    iconCls'employee-add',   
        
    handler: function( btneopts ) {       
            
    rowEditing.cancelEdit();       
            var 
    Ext.create('ONC.model.DataPoliklinikRuanganModel'),           
                  
    store btn.up'grid' ).getStore() ;       
            
    store.insert(0r);       
            
    rowEditing.startEdit(00);   
        }


  3. #3
    Sencha User ekolesmanasijabat's Avatar
    Join Date
    Dec 2012
    Posts
    6
    Vote Rating
    0
    ekolesmanasijabat is on a distinguished road

      0  

    Default


    Thanks again exitdissolve ,

    your solution is working for me. but when i click the "Add Employee" button, it's only insert one record to the grid, then i must double click the record to edit/insert data inside it . What i want is, when i click the "Add Employee" button, it will be automatically to make the record editable...
    Eko Lesmana Sijabat

    #Our Creator, Science, and Us#
    w: http://www.triwahana.com/
    e: eko@triwahana.com

  4. #4
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    Quote Originally Posted by ekolesmanasijabat View Post
    Thanks again exitdissolve ,

    your solution is working for me. but when i click the "Add Employee" button, it's only insert one record to the grid, then i must double click the record to edit/insert data inside it . What i want is, when i click the "Add Employee" button, it will be automatically to make the record editable...
    According to the docs, the arguments for startEdit are record and columnHeader.

    So if you update your code to something like the following, it should work:

    PHP Code:
    grid.editingPlugin.startEditstore.getAt(0), grid.columns[0] ); 
    Here's a live example: Editable Grid after Store Insert

  5. #5
    Sencha User ekolesmanasijabat's Avatar
    Join Date
    Dec 2012
    Posts
    6
    Vote Rating
    0
    ekolesmanasijabat is on a distinguished road

      0  

    Default


    finally i got where is my mistake. because of the listeners. when i comment in that line, everything is worked fine.

    anyway, thanks a lot for your solution, exitdissolve. at least, make me know what variables and actions that can handle in grid.
    Eko Lesmana Sijabat

    #Our Creator, Science, and Us#
    w: http://www.triwahana.com/
    e: eko@triwahana.com

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    11
    Vote Rating
    1
    bruce1058 is on a distinguished road

      0  

    Default Works but doesn't follow documentation

    Works but doesn't follow documentation


    Quote Originally Posted by existdissolve View Post
    According to the docs, the arguments for startEdit are record and columnHeader.

    So if you update your code to something like the following, it should work:

    PHP Code:
    grid.editingPlugin.startEditstore.getAt(0), grid.columns[0] ); 
    Here's a live example: Editable Grid after Store Insert
    grid.columns[0] does not return a Ext.data.Model which is the documented type of the column variable to startEdit. Documentation should be corrected. Addtitionally, the column argument as index does not work in the current 4.2.883 release. Also not documented

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi