2

I'm using data grid table in voyager Laravel.. its working properly how ever I need to disable or hide editing options to normal user on the basis of roles Assigned.

onCellPrepared: function(e) {
    var role = "<?php echo setting('admin.Admin_role_id') ?>";
    var userrole = "<?php echo setting('site.normal_user_role_id') ?>";

    // alert(role);
    if (role == 1) {
        console.log(role);
        e.component.element().find('.dx-command-edit').show();
    }

    if (userrole == 2) {
        console.log(userrole);
        e.component.element().find('.dx-command-edit').hide();
    }
}
Priyanka khullar
  • 479
  • 1
  • 5
  • 23
Uddyan Semwal
  • 564
  • 1
  • 6
  • 20
  • Please explain your problem with more details giving a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your attempt, noting input and expected output. – Islam Elshobokshy Oct 09 '18 at 12:14

1 Answers1

1

I solved it out as I need to give access of edit option only to my admin. I have solved this problem like this

var is_editable = false;
var role = "<?php echo setting('admin.Admin_role_id') ?>";

@if(Auth::user()->role_id == setting('admin.Admin_role_id', 1))

is_editable = true;

@endif



editing: {
            mode: "popup",
            allowAdding: is_editable,
            allowDeleting: is_editable,
            allowUpdating: is_editable,
            popup: {
                title: "Employee Attendance  Information",
                showTitle: true,
                id: "employees->id",
                position: {
                    my: "top",
                    at: "top",
                    of: window
                }
            }
        },
Uddyan Semwal
  • 564
  • 1
  • 6
  • 20