EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Pierre on May 05, 2017, 05:52:11 AM



Title: [SOLVED] Checkbox state on grid editor
Post by: Pierre on May 05, 2017, 05:52:11 AM
Hello
How to know what is checkbox state when user clicked on checkbox on datagrid?
I'm using Cell Editing extension.
I know how to use onCellEdit and onAfterEdit events but they are fired before and after click on cell and I need some Event in the moment when user changed checkbox state (from unchecked to checked and vice-versa).
Thank you.


Title: Re: Chechbox state on grid editor
Post by: jarry on May 05, 2017, 06:50:44 PM
Listen to the 'onCellEdit' event, get the 'checkbox' editor and then you can bind the 'change' event on it. Please look at the code below:
Code:
$('#dg').datagrid({
    data: data,
    onCellEdit: function(index,field,value){
        if (field == 'status'){
            var ck = $(this).datagrid('getEditor', {index:index,field:field});
            $(ck.target).bind('change', function(e){
                //...
            })
        }
    }
}).datagrid('enableCellEditing').datagrid('gotoCell', {
    index: 0,
    field: 'productid'
});


Title: Re: Chechbox state on grid editor
Post by: Pierre on May 08, 2017, 01:35:34 AM
Awesome Jarry, it works perfect.
Thank you so much for your help.