首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

【转载】关于ExtJS的工具栏动态增添按钮(从后台数据库读取信息)

2012-11-23 
【转载】关于ExtJS的工具栏动态添加按钮(从后台数据库读取信息)?转载:http://www.cnblogs.com/wangsj/archiv

【转载】关于ExtJS的工具栏动态添加按钮(从后台数据库读取信息)

?

转载:http://www.cnblogs.com/wangsj/archive/2010/05/25/1743338.html

问题讨论:http://home.cnblogs.com/group/topic/39468.html

作者:王善军

?

?

?

?

?

我想在工具栏中动态添加按钮,至于添加什么按钮,则从后台数据库中读取信息。

后台代码(C#)

?

?

?

但JS怎么写呢?这个问题困扰了我很久。开始写了以下代码,但不成功:

?

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 SetToolButtons = function(tbr) {     Ext.Ajax.request({         url: 'rolegroup.aspx',         params: '',         method: 'POST',         success: function(response, options) {             var rsp = Ext.util.JSON.decode(response.responseText);             var total = rsp.totalProperty;             var arrays = new Array(total);             for (var i = 0; i < total; i++) {                 arrays[i] = new Ext.Toolbar.Button({ text: rsp.result[i].text, iconCls: 'icon-home' });             }             tbr.add(arrays);             tbr.addFill();             tbr.addButton(             {                 text: '我的桌面',                 iconCls: 'icon-desktop',                 scope: this             });             tbr.addSeparator();             tbr.addButton([             {                 text: '重新登录',                 iconCls: 'icon-user'             },             {                 text: '退出系统',                 iconCls: 'icon-exit'             }]);         },         failure: function() {             Ext.Msg.alert("提示信息", "按钮加载失败,请稍后重试!");         }     }); };  Ext.onReady(function() {     Ext.QuickTips.init();     var toolbar = new Ext.Toolbar({         id: 'tool_bar',         cls: 'top-toolbar'     });     SetToolButtons(toolbar); }
?

?

?

先创建好工具栏,我再添加按钮,而且是一次性添加好。结果运行成功!

我查了许多网友提供的资料,结合大家的思路,才有以上代码,在此衷心感谢广大网友!

?

?

希望本文对大家有帮助!

?

热点排行