========
can_view
========

.. js:function:: can_view()

**domain**: client 

**language**: javascript

**class** :doc:`AbstractItem </refs/client/abstractitem_api>`

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

Use **can_view** method to determine if a user have a right to get access to an
:doc:`item </refs/client/item_api>` 
dataset or to see report generated by 
:doc:`report </refs/client/report_api>`
when the project 
:doc:`Safe mode parameter </admin/project/parameters>`
is set. If the 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.visible && item.can_view()) {
        $("#submenu")
            .append($('<li></li>')
            .append(
                $('<a href=""></a>')
                    .text(item.item_caption)
                    .data('item', item);
            )
        );
    }
