Title: How to hide or disable/hide easyui-link button where user not admin Post by: dearsh 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. Title: Re: How to hide or disable/hide easyui-link button where user not admin Post by: stworthy 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'); Title: Re: How to hide or disable/hide easyui-link button where user not admin Post by: dearsh 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 } ?> Title: Re: How to hide or disable/hide easyui-link button where user not admin Post by: stworthy 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', { Title: Re: How to hide or disable/hide easyui-link button where user not admin Post by: dearsh on May 04, 2014, 06:30:36 AM SOLVED
Thx stworthy. |