Resource Grouping with permissions

6 posts, 0 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 13 Sep Link to this post

    I already have a calendar setup with Resource Grouping and now would like to setup permissions so that some users can only admin certain resources but see all. I would handle the determination of right so that each resource would have a flag set as something like adminAllowed and when that is true the resource can be booked.  Is this possible, I'm fairly sure that it is possible via the client API but want to check before I waste any time on it.

    Regards

    Jon

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    278 posts

    Posted 16 Sep Link to this post

    Hello Jon,

    To achieve the desired you could use a combination of server-side and client-side events, exposed by the RadScheduler. Based on our Resource grouping demo, I could suggest you to use the OnAppointmentCreated server-side event to make some of the events not editable and not deletable, depending on which resource they belong to:
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        var appointment = e.Appointment;
        var resource = appointment.Resources[0];
        int key;
     
        if (int.TryParse(resource.Key.ToString(), out key) && key == 1)
        {
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
        }
    }

    To prevent event creation, depending on the current resource, you could use the OnClientAppointmentInserting client-side event:
    function inserting(sender, args) {
        var targetSlot = args.get_targetSlot();
        var resourceKey = targetSlot.get_resource().get_key();
        if (resourceKey == 1) {
            args.set_cancel(true);
        }
    }

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 16 Sep in reply to Veselin Tsvetanov Link to this post

    Hi Veselin

    Many thanks - the appointment created bit works very well.

    On the client side though I need to be able to get the true/false value for admin permission from the resource.  There doesn't appear to be an event that I can attach to in order to add extra values.  For example on the scheduler itself I use the CustomAttributeNames to add extra attributes to the appointments but there doesn't appear to be something for the resources - or did I miss something?

    Regards

    Jon

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    278 posts

    Posted 17 Sep Link to this post

    Hello Jon,

    You could use the TimeSlotCreated event of the RadScheduler to attach custom attributes to the resource that is associated with a specific TimeSlot:
    protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        var timeSlot = e.TimeSlot;
        var resource = timeSlot.Resource;
        int key;
     
        if (int.TryParse(resource.Key.ToString(), out key) && key == 1)
        {
            resource.Attributes.Add("alowedManipulation", "notAllowed");
        }
    }

    Then, again in the OnClientAppointmentInserting, you could retrieve that value and based on that you could cancel the event:
    function inserting(sender, args) {
        var targetSlot = args.get_targetSlot();
        var resource = targetSlot.get_resource();
        var allowed = resource.get_attributes().getAttribute("alowedManipulation");
        if (allowed == "notAllowed") {
            args.set_cancel(true);
        }
    }

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 17 Sep in reply to Veselin Tsvetanov Link to this post

    Hi Veselin

    Thanks for that - it certainly looks like that will get me close to the solution.  The permission "AdminPermissionAllowed" I have coming from the database though in the resource data source so ideally it would get the data from there.  In the resource object that you get in the timeslotcreated event there is a dataitem.  It is always blank though.  Is there no way to add extra attributes from the database?

    If not then I will just have to get the resource data a second time in the pageload event and make a list of the resources that have permission allowed with a reference to that in the timeslotcreated event.  

    Regards

    Jon

     

     

  7. Peter Milchev
    Admin
    Peter Milchev avatar
    135 posts

    Posted 21 Sep Link to this post

    Hello Jon, 

    I am afraid that currently it is not possible to use the "AdminPermissionAllowed" value of the Database object directly and  you should use the approach Veselin suggested - by adding manually attributes to the resource.

    Regards,
    Peter Milchev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017