Results 1 to 2 of 2

Thread: Dynamically load data to grid.

  1. #1
    Sencha User
    Join Date
    Oct 2014
    Posts
    32

    Default Dynamically load data to grid.

    Hello. I need help.
    I have grid with toolbar when i create new grid with data (open window of create via button in toolbar)
    the new row not displayed only after reloading the page i see the new row.
    Thank you.

    the store:
    Code:
    var writer = new Ext.data.JsonWriter({
        type: 'json',
        encode: false,
        listful: true,
        writeAllFields: true,
        returnJson: true
    });
    
    
    var reader = new Ext.data.JsonReader({
        totalProperty: 'total',
        successProperty: 'success',
        idProperty: 'Id',
        root: 'Data',
        messageProperty: 'message'
    });
    
    
    var proxy = new Ext.data.HttpProxy({
        reader: reader,
        writer: writer,
        type: 'ajax',
        api: {
            read: '/Item/Get',
            create: '/Cart/CreateCart',       
            update: '/Cart/CreateCart',
            destroy: '/Cart/CreateCart',
            add: '/Cart/CreateCart'
        },
        headers: {
            'Content-Type': 'application/json; charset=UTF-8'
        }
    });
    
    
    Ext.define('ExtMVC.store.Items', {
        extend: 'Ext.data.Store',
        model: 'ExtMVC.model.Item',
        autoLoad: true,
        paramsAsHash: true,
        autoSync: true,
        proxy: proxy    
    });
    Creating item:
    Code:
    additem: function (button) {
            var win = button.up('window'),
                form = win.down('form'),
                values = form.getValues();
            Ext.Ajax.request({
                url: 'Item/CreateItem',
                params: values,
                success: function (response, options) {
                    var data = Ext.decode(response.responseText);
                    if (data.success) {
                        Ext.Msg.alert('Create', data.message);                    
                    }
                    else {
                        Ext.Msg.alert('Create', 'Creating is faild');
                    }
                    win.close();
                }
            });
        }

  2. #2
    Sencha User
    Join Date
    Oct 2014
    Posts
    32

    Default The answer.

    Code:
    var win = button.up('window'),
                form = win.down('form'),
                values = form.getValues();
                var grid = Ext.getCmp('gridit');
                var store = grid.getStore();
                var model = Ext.ModelMgr.getModel(store.model);
                var record = model.create();
                record.set(values);
                store.add(record);           
                store.sync();

Tags for this Thread

Posting Permissions

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