ExtJs常用功能
1.判断内容是否修改
1)
var cgrid = query_panel.cgrid; var v = cgrid.getValues(); //console.log(v); if (v != "" && typeof (v) != "undefined") { Ext.Msg.alert(MsgMrg.OptMsg, '修改信息后请先保存!'); return; }
2)
if (cgrid.getStore().getModifiedRecords().length > 0) { Ext.Msg.alert(MsgMrg.OptMsg, '修改信息后请先保存!'); return; }
2.获取选中行的某个值
listeners: { beforeload: function (v) { debugger Ext.apply(v.baseParams, { //SFields: ["USERID"],// //SFieldTypes: ['string'], //Relations: ["="], //SValues: ['qcy'], UserId:grid.getSelectionModel().getSelected().get('UserID') }); } }
3.后台返回json格式的输出
return "{success:false,msg:'不存在此按钮'}";
4.前台渐变弹窗
prityTip(MsgMrg.OptMsg, '已是启用状态!');
5.点击后弹出输入文本框弹窗
Ext.Msg.prompt(MsgMrg.OptMsg, "请填写启用原因", function (btn, text) { if (btn == "ok") { if (text == '' || text == null) { Ext.Msg.alert(MsgMrg.OptMsg, '请填写启用原因!'); return; } //mainfunction } })
6.根据列名获取在列中索引
var i= c_gridColumns.findColumnIndex("name");
7.store加载完后执行事件
store.load({ callback: function () { var rec = store.getAt(0); console.log(rec); form_panel.getForm().reset(); if (rec) { form_panel.getForm().loadRecord(rec); } } });
8.成功后选中状态失去
grid.success = function () { grid.getStore().load({ callback: function () { grid.getStore().queryBy(function (r) { debugger; if (r.data.ID== curId) { var arr = [r]; grid.getSelectionModel().selectRecords(arr); //grid.success(); return true; } }) } }); };