========
can_edit
========

.. js:function:: can_edit()

**domain**: client 

**language**: javascript

**class** :doc:`Item </refs/client/item_api>`

Description
===========

Use ``can_edit`` method to determine if a user have a right to edit a record in
in an item dataset when the project 
:doc:`safe mode parameter </admin/project/parameters>`
is set. If the project project 
:doc:`safe mode parameter </admin/project/parameters>`
is not set the method always returns true.

The user privileges are set in the :doc:`roles node </admin/roles>` of the project 
tree.

Example
=======

.. code-block:: js

    if (item.can_edit()) {
        item.view_form.find("#edit-btn").on('click', 
            function() {
                item.edit_record();
            }
        );
    }
    else {
        item.view_form.find("#edit-btn").prop("disabled", true);
    }
