Easyui_ Dynamic Add hidden toolbar button

Source: Internet
Author: User

target: Dynamically add hidden toolbar, such as dynamic display of new, modified, delete buttons, etc. according to permissions
idea: First initialize all buttons of toolbar, load other DataGrid information, and then Show hidden toolbar button according to permission
steps:1. Loading steps
12345 $(function() {    easyToolbarInit();     //初始化toolbar按钮    easyInitGrid({title:"管理",url:"/sa/add"});  //加载datagrid其它信息,如列等    easyToolbarDisplay();  //根据权限显示/隐藏 toolbar按钮  张          });


2, Initialize the toolbar button (the ID of the button is the identity information used later, it is best to use the complete information, to prevent conflicts with other IDs?)

1234567891011121314151617181920212223 //初始化toolbar按钮function easyToolbarInit() {        $(‘#grid‘).datagrid({        toolbar : [ {            id : ‘add‘,                text : ‘添加‘,            iconCls : ‘icon-add‘,            height : 50,            handler : function() {                gridAdd();            }        }, ‘-‘, {            id : ‘delete‘,            text : ‘删除‘,            iconCls : ‘icon-remove‘,            height : 50,            handler : function() {                gridDelete();            }        } ]    });}

3. Loading the DataGrid other information


4. Show/Hide toolbar button According to permissions

123456789101112131415 function easyRightDisplay() {    //获取所有的toolbar按钮    var button=$(‘div.datagrid div.datagrid-toolbar a‘);     for (var i = 0; i < button.length; i++) {        var toolbar = button[i];        var id = toolbar.id;        if (id == "add") {  //隐藏Id为add的按钮            $(‘div.datagrid div.datagrid-toolbar a‘).eq(i).hide();        }        if (id == "delete") {  //不隐藏id为delete的按钮            //button.eq(i).hide();        }        //如果按钮都没权限,隐藏了可直接隐藏toolbar        //$(‘div.datagrid div.datagrid-toolbar‘).hide();    }



From for notes (Wiz)

Easyui_ Dynamic Add hidden toolbar button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.