EasyUI Forum
March 28, 2024, 09:25:37 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: disable linkbutton inside datagrid  (Read 10378 times)
crosemffet
Jr. Member
**
Posts: 68



View Profile WWW Email
« on: December 09, 2015, 01:11:13 PM »

hello everybody, and thanks in advance for your support,
maybe it's a simple question, but after 14 hs of programming  today I'm a little confused:
$('#myButton').linkbutton('disable'); --> works ok, disable the button myButton

my problem is myButton is inside datagrid the disable method is not working:
<table class=easyui-datagrid>
<td><a href=# class=easyui-linkbutton id=myButton>Hello World!</a></td>
</table>

in this code, $('#myButton').linkbutton('disable'); doesn't seems to work.
what am I doing wrong...? thanks again for your invaluable support.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 10, 2015, 06:14:22 AM »

The datagrid only parses the plain data from <table> element, the components on the cell will be parsed as html data. Please prevent from defining auto parsed components directly on the cell. The alternative solution to solve this issue is to define the components with non 'easyui-' class and then create these components after loading data successfully.

Code:
<table id="dg">
<td><a href=# class=e-linkbutton id=myButton>Hello World!</a></td>
</table>
<script>
$(function(){
    $('#dg').datagrid({
        onLoadSuccess: function(){
            $(this).datagrid('getPanel').find('.e-linkbutton').linkbutton();
        }
    })
})
</script>
Logged
crosemffet
Jr. Member
**
Posts: 68



View Profile WWW Email
« Reply #2 on: December 10, 2015, 02:43:23 PM »

hey sworthy, you save my day as usual.
everything you propose works perfect, except for one point:
when I use your solution, and assign icon-cls to the button, for one unknown reason the icon shows two times.
the code:
$(this).datagrid('getPanel').find('.e-linkbutton').linkbutton({plain:true,iconCls:'icon-add'};
shows the button, but with two plus signs together (" + + ")
is not the end of the world, but maybe you can check it... thanks in advance,
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 10, 2015, 06:13:15 PM »

Please refer to this example http://jsfiddle.net/xnpLzo3v/
Logged
bduguay
Newbie
*
Posts: 31


View Profile
« Reply #4 on: May 25, 2017, 05:33:00 AM »

I know this is an old thread, but how do you enable/disable the button within the datagrid/treegrid?

I have my formatter create the button
Code:
function buttonFormatter(buttonText, row, ca) {
    return '<a href="#" id="btn' + row.id + '" class="e-linkbutton" data-options="width:57">' + buttonText + '</a>';
}
but when I go to disable the button with the following code, nothing happens
Code:
$('#btn' + row.id).linkbutton('disable');

Any help would be appriciated.
Thank you.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: May 27, 2017, 01:26:54 AM »

Please make sure that the button exists before calling the 'disable' method.
Code:
var btn = $('#btn' + row.id);
console.log(btn);
Logged
bduguay
Newbie
*
Posts: 31


View Profile
« Reply #6 on: May 29, 2017, 07:29:07 AM »

Hi stworthy,

This is the results of the console.
Logged
bduguay
Newbie
*
Posts: 31


View Profile
« Reply #7 on: June 05, 2017, 07:05:03 AM »

I've figure out the answer
Code:
$('#btn' + row.id).linkbutton('disable');
$('#btn' + row.id.prop('isConnected', false);

and then refresh the grid buttons
Code:
$('#dg).datagrid('getPanel').find('.e-linkbutton').linkbutton();
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!