ExtJs学习--实用功能代码段

一、图表保存成图片自动下载

tbar: [{
            text: 'Save Chart',
            handler: function() {
                Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
                    if(choice == 'yes'){
                        chart.save({
                            type: 'image/png'
                        });
                    }
                });
            }
        }]
二、点击gridpanel动态更新panel的内容

1.新建一个Ext.Template,例如:

    var bookTplMarkup = [
        'Title: <a href="{DetailPageURL}" target="_blank">{Title}</a><br/>',
        'Author: {Author}<br/>',
        'Manufacturer: {Manufacturer}<br/>',
        'Product Group: {ProductGroup}<br/>'
    ];
    var bookTpl = Ext.create('Ext.Template', bookTplMarkup);

2.grid代表点击的gridpanel,detailPanel为要更新内容的panel,绑定事件,

grid.getSelectionModel( ).on('selectionchange',function(me,selectionrecord){

if(selectionrecord.length){

var detailPanel=Ext.getCmp('detailPanel');

bookTpl.overwrite(detailPanel.body,selectionrecord[0].data)

}

})

三、常用代码段

Ext.Ajax.Request

   Ext.Ajax.request({
      url : 'question/question/audit',
      method : 'POST',
      params : {
       'questionId':modelArray[0].raw.questionId,
       'result':btn.action
      },
      success : function(rec, opt) {
       Ext.Msg.alert('信息提示','审核成功!!');
       Ext.ComponentQuery.query('qualifiedview #questionlist')[0].getStore().load();
       win.close();
       //win.down('#ckeditor').setValue(obj.datas[0].content);
      },
      failure : function(e, op) {
       Ext.Msg.alert("发生错误", op.error);
      }
     });

Form.Submit

   form.submit({
      url : $baseUrl + '/number/number/import',
      waitMsg : '正在上传处理过程中...',
      success : function(form, action) {
       var ii = '';
       if (action.result.msg == '上传成功') {
        ii = action.result.msg;
       } else {
        ii = action.result.msg;
       }

       win.close();
       var store = Ext.ComponentQuery.query('#numberlist')[0].getStore();
       var proxy = store.getProxy();
       proxy.extraParams = '';
       store.load();
       Ext.Msg.alert('操作提示', ii);
      },
      failure : function(form, action) {
       win.close();
       Ext.Msg.alert('操作提示', action.result.msg);
      }

     });


store setExtraParam

store.getProxy().setExtraParam('status', status);


固定store的combobox

1、  var locationStore = Ext.create('Ext.data.Store', {
fields : ['value', 'text'],
data : {
'items' : [{
value : 1,
text : '导航条下方'
}, {
value : 2,
text : '招聘信息上方'
}, {
value : 3,
text : '求职信息上方'
}, {
value : 4,
text : '求职信息下方'
}]
},
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'items'
}
}
});

2、

{
xtype : 'combobox',
name : 'location',
fieldLabel : '显示位置',
store : locationStore,
displayField : 'text',
valueField : 'value',
editable : false
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值