EasyUI Forum
May 20, 2024, 05:00:00 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to hide or disable/hide easyui-link button where user not admin  (Read 19744 times)
dearsh
Newbie
*
Posts: 16

arif_yes06
View Profile Email
« on: April 30, 2014, 12:59:10 AM »

Hi,

I have two type user ( ADMIN and OPERATOR) who access a page with easyui tab.
This is my script
function addTab_user(title){
            if($('#tab_content').tabs('exists',title)){
               $('#tab_content').tabs('select', title);
            } else {
               var content = "<div title='tb_user' iconCls='icon-home' closable='true' style='overflow:hidden;padding:5px'>";
               content += "<table id='tb_user' title='Data User' class='easyui-datagrid' style='width:auto;height:350px;'";
               content += "url='model/tb_user/get_user.php' toolbar='#toolbar_tb_user' rownumbers='true' singleSelect='true' pagination='true' nowrap='false' striped='true'>";
               content += "<thead>";
               content += "<tr>";
                  content += "<th field='id' width='100' hidden='true'>ID</th>";
                  content += "<th field='username' width='300'>Username</th>";
                  content += "<th field='password' width='50' hidden='true'>Password</th>";
                  content += "<th field='nama_lengkap' width='350'>Nama Lengkap</th>";
                  content += "<th field='akses' width='200'>Akses</th>";
                  content += "<th field='status' width='150'>Status</th>";
               content += "</tr>";
               content += "</thead>";
               content += "</table>";
               content += "<div id='toolbar_tb_user'>";
                  content += "<a href='#' class='easyui-linkbutton add-adm' iconCls='icon-add' plain='true' onclick='tambah_user()'>Add </a>";
                  content += "<a href='#' class='easyui-linkbutton' iconCls='icon-edit' plain='true' onclick='edit_user()'>Edit</a>";
                  content += "<a href='#' class='easyui-linkbutton delete-adm' iconCls='icon-remove' plain='true' onclick='hapus_user()'>Delete</a>";
               content += "</div>";
               content += "</div>";
               $('#tab_content').tabs('add', {
                  title: title,
                  content: content,
                  iconCls: 'icon-home',
                  closable: true
               });
            }
         }

My Problem is How to Disable or Hide link button easyui-linkbutton add-adm & easyui-linkbutton delete-adm in div toolbar_tb_user where user not ADMIN.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 30, 2014, 01:39:59 AM »

Call 'disable' method to disable a linkbutton or call 'enable' method to enable it.
Code:
$('#btn').linkbutton('disable');
$('#btn').linkbutton('enable');
Logged
dearsh
Newbie
*
Posts: 16

arif_yes06
View Profile Email
« Reply #2 on: May 01, 2014, 08:26:50 PM »

I write this code above function addTab_user but still not effect.
This is my code

<?php
         $akses = $_SESSION['s_akses'];
         if($akses == "ADMIN"){
            ?>
            <script type="text/javascript">
               $('#btn-adm').linkbutton('enable');
            </script>
            <?php
         } else {
            ?>
            <script type="text/javascript">
               $('#btn-adm').linkbutton('disable');
            </script>
            <?php
         }
      ?>

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: May 02, 2014, 03:42:40 AM »

Before call 'disable' method to disable a linkbutton, the linkbutton must be exists. Your disabling code must be inserted after the 'addTab_user' function.
Code:
$('#tab_content').tabs('add', {
  //...
});
<?php
...
$(
'#btn-adm').linkbutton('disable');
?>

Logged
dearsh
Newbie
*
Posts: 16

arif_yes06
View Profile Email
« Reply #4 on: May 04, 2014, 06:30:36 AM »

SOLVED

Thx stworthy.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!