How can we reload store and refresh grid on button click in following code?

Total Post:26

Points:182
C# 
C#
 655  View(s)
Ratings:
Rate this:

How can we reload store and refresh grid on button click in following code?

updateClick:
function (field,
newValue, oldValue) {  //updateClick function call on update button click
        console.log(field);
        var me = this;
        var form = Ext.getCmp('userForm'); //get component of userForm and assign value into form variable
        var values = form.getValues(); //call getValue function by association of form variable and assign into values variable
        Ext.Ajax.request({     //send Ajax request to MVC controller request
            url: './User/Update',   //give path of method define in MVC controller
            method: 'POST',     //use POST method
            jsonData: values,   //send values in the form of jsonData
            success: function (response) {      //define success function
                var result = Ext.decode(response.responseText);
                if (result.success === true) {
                    Ext.Msg.show({
                        title: 'EMPLOYEE',
                        msg: result.message,
                        buttons: Ext.Msg.OK,
                        icon:Ext.MessageBox.INFORMATION
                    });
                }
                else {
                    Ext.Msg.show({
                        title: 'EMPLOYEE',
                        msg: result.message,
                        buttons: Ext.Msg.OK,
                        icon:Ext.MessageBox.ERROR
                    });
                }
            },
            failure: function () {  //define failure function on response of mvc controller
                Ext.Msg.show({
                    title: 'Record not Updated',
                    msg: result.message,
                    buttons: Ext.Msg.OK,
                    icon: Ext.MessageBox.ERROR
                });
            }
        });
    },
  1. Post:44

    Points:310
    Re: How can we reload store and refresh grid on button click in following code?

    You can use following code under success function

      
    var store = Ext.getCmp('userGridFooter').getStore();
                        store.reload();
                        Ext.getCmp('userGridFooter').getView().refresh();


    Your Code


    updateClick:
    function (field,
    newValue, oldValue) {  //updateClick function call on update button click
            console.log(field);
            var me = this;
            var form = Ext.getCmp('userForm'); //get component of userForm and assign value into form variable
            var values = form.getValues();//call getValue function by association of form variable and ssign into values variable
            Ext.Ajax.request({     //send Ajax request to MVC controller request
                url: './User/Update',   //give path of method define in MVC controller
                method: 'POST',     //use POST method
                jsonData: values,   //send values in the form of jsonData
                success: function (response) {      //define success function
                    var result = Ext.decode(response.responseText);
                    if (result.success === true) {  //window.location.reload();
                        var store = Ext.getCmp('userGridFooter').getStore();
                        store.reload();
                        Ext.getCmp('userGridFooter').getView().refresh();
                        Ext.Msg.show({
                            title: 'EMPLOYEE',
                            msg: result.message,
                            buttons: Ext.Msg.OK,
                            icon:Ext.MessageBox.INFORMATION
                        });
                    }
                    else {
                        Ext.Msg.show({
                            title: 'EMPLOYEE',
                            msg: result.message,
                            buttons: Ext.Msg.OK,
                            icon:Ext.MessageBox.ERROR
                        });
                    }
                },
                failure: function () {  //define failure function on response of mvc controller
                    Ext.Msg.show({
                        title: 'Record not Updated',
                        msg: result.message,
                        buttons: Ext.Msg.OK,
                        icon: Ext.MessageBox.ERROR
                    });
                }
            });
        },

      Modified On Feb-17-2017 07:10:11 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!