EasyUI Forum

General Category => General Discussion => Topic started by: ltpitt on May 06, 2014, 04:18:09 PM



Title: [SOLVED] Disable editing on in onBeforeEdit in Datagrid
Post by: ltpitt on May 06, 2014, 04:18:09 PM
Hi all!

I would like to disable editing if the user click in a row with a specified value in column.

I tried this but I get an error...
What can solve the problem?

    function onBeforeEdit(rowIndex, rowData) {
        if (rowData.AggiornaInventario == -1 ){
            $.messager.alert('Riga non modificabile','I dati di questo materiale sono gi&agrave registrati in magazzino','error');
            rowIndex.editor = null;
                    } else {
                return true;
                            }
        }


Title: Re: Disable editing on in onBeforeEdit in Datagrid
Post by: stworthy on May 06, 2014, 04:55:17 PM
Please try this:
Code:
function onBeforeEdit(rowIndex, rowData) {
if (rowData.AggiornaInventario == -1 ){
$.messager.alert('Riga non modificabile','I dati di questo materiale sono gi&agrave registrati in magazzino','error');
return false;
} else {
return true;
}
}


Title: Re: Disable editing on in onBeforeEdit in Datagrid
Post by: ltpitt on May 07, 2014, 05:30:06 AM
Hi and thanks for help!

If I try your solution the editing is totally disabled (even in rows where it should work) and I get an error:

"Uncaught TypeError: Cannot read property 'target' of undefined "


Title: Re: Disable editing on in onBeforeEdit in Datagrid
Post by: stworthy on May 07, 2014, 05:38:19 PM
Please try the attached example. It works fine.


Title: Re: Disable editing on in onBeforeEdit in Datagrid
Post by: ltpitt on May 13, 2014, 06:19:02 AM
Classy!

Thanks a ton :)