In today's coding process, I found that there is a slight difference in the return value between the request submitted by the button and the direct ajax request.
View direct ajax
Ext.Ajax.request({url : "../UserSelectAllServlet",method : 'POST',success : function(response) {var json = Ext.JSON.decode(response.responseText); //column = new Ext.grid.column.Column(json.columModle);//alert(json.data[2].id);var store = Ext.create('Ext.data.Store', {fields : json.fields,data : json.data});Ext.getCmp("grid_a").reconfigure(store, json.columns);}});
This code requests the servlet to obtain the returned value as a json string, which must be transcoded into a json object using ext. json. decode. The following code can operate on this json object:
Let's look at the form submission request of the button.
Form. submit ({success: function (form, action) {// Ext. msg. alert ('success', action. result. msg); // console. log (action. result. log); var json = action. result. log; // column = new Ext. grid. column. column (json. columModle); // alert (json. data [2]. id); var store = Ext. create ('ext. data. store', {fields: json. fields, data: json. data}); Ext. getCmp ("grid_a "). reconfigure (store, json. columns); // Ext. getCmp ("grid "). render (); grid_a.show ();}/*, failure: function (form, action) {Ext. msg. alert ('failed', "Failed ");}*/});
This code is a form submission request. The object obtained using action. result does not need to be converted to json format again ..
I just learned extjs .. If your understanding is incorrect, please point it out directly ..