Grid Data Visibility and Editability

Learn how to filter out data in the search results and control the ability to select and edit records in the search results.

Here is the converted HTML content in Markdown format:


Controlling the Editability of Records

When you want to disable editing of records in the search results, you must add a Virtual Field with the resource ID: _readonly to the Entity. Once you create this field you must provide an SQL expression that returns a boolean value in the Field's Properties > Custom Server Side Scripts.

  • _readonly value of true or 1disables editing of the record.

  • _readonly value of false or 0enables editing of a record.

See Custom Filters and SQL Expressions for Virtual Fields for more details on how to specify the SQL Expression.


Controlling the Selectability of Records

When you want to disable the selection of records in the search results, you can use the _readonly field created above or you must add a Virtual Field with the resource ID: _disableSelection to the Entity. Once you create this field you must provide an SQL expression that returns a boolean value in the Field's Properties > Custom Server Side Scripts.

  • _readonly OR _disableSelection value of true or 1disables the selection of the record.

  • _readonly OR _disableSelection value of false or 0enables the selection of a record.

See Custom Filters and SQL Expressions for Virtual Fields for more details on how to specify the SQL Expression.


Hiding Data from the Search Results with Custom Filters

You can control data visibility using custom filters provided in the Field's Properties > Custom Server Side Scripts. For example, we may want to show a logged-in user only the tasks assigned to them.

See Custom Filters and SQL Expressions for Virtual Fields for more details on how to specify custom filters.


Example

IMPORTANT:

Make sure you have completed the running of the Sample Application tutorial before continuing.

The Sample Application using the XLib.Samples.Todo library has implemented the following role-based requirement:

Role

View Self Tasks

View Other's Tasks

Edit Self Tasks

Edit Other's Tasks

Admin

YES

YES

YES

YES

Manager

YES

YES

YES

NO

Assistant

YES

NO

YES

NO


To implement this requirement, do the following in the XLib.Samples.Task Entity.

  • For the Assigned To ID Field: Apply a Custom Filter in the Properties > Custom Server Side Scripts property. This filter implements the visibility of data as per the above condition. Note: This field is hidden. Turn ON the Show Hidden Fields toggle.

  • Create a new field with resource ID _readonly. Assign an SQL Expression in the Properties > Custom Server Side Scripts property that returns a boolean value as per the editability requirement.

You may use the following credentials in your sample application:

Username

Password

Role

sysadmin

demo@164#conti

Admin

johndoe

demo@164#conti

Manager

briansmith

demo@164#conti

Assistant