- Ajax範例
//啟動時遮照 Ext.Ajax.on('beforerequest', function () { Ext.getBody().mask("Loading"); }, this); //結束時移除遮照 Ext.Ajax.on('requestcomplete', function () { Ext.getBody().unmask(); }, this); var paramObj = new Object(); paramObj.id = "123"; //Ext.getBody().mask("Loading2"); Ext.Ajax.request({ url: "MyAjax.jsp", scope: this, method: "post", success: function ( response) { Ext.getBody() .unmask(); var json = Ext.decode(response.responseText); //{success:false|true,msg:'訊息'} if (json.success) { //回傳success要做的事 } else { //錯誤時alert alert(json.msg); } }, // .createDelegate(this), failure: function () { if (action.response.status == 200) { var json = Ext.decode(action.response.responseText); Ext.MessageBox.alert(json.msg); } else Ext.MessageBox.alert("Save Error~"); }, params: paramObj });
分類: javascript
javascript相關
[ExtJS]Grid常用function
- 取得選取列資料
var sm = obj.grid.getSelectionModel();
var record = sm.getSelections();
record回傳的是個陣列array
var index = grid.store.indexOf(record[0]);
回傳的index是一個數字