Readonly some event

Here is my code

function block_readonly(id){ if (id) return true; if (this.getEvent(id).user_id!=<?php echo $user_id;?>) return false; } scheduler.attachEvent("onBeforeDrag",block_readonly) scheduler.attachEvent("onClick",block_readonly)
Error is this.getEvent(id).user_id havent define yet! Please help me!
p/s: Anyway that set some event readonly form the server side, not viewer side?

I also have similar problem with above. please help?

[code]scheduler.attachEvent(“onBeforeDrag”, block_readonly)
scheduler.attachEvent(“onDblClick”, block_readonly)

    function block_readonly(id){
            if(id != undefined) {
                var event = scheduler.getEvent(id);
                return !event.readonly;
            }
    }

[/code]

make sure you have the readonly variable set to the event as boolean.

scheduler.Parse([{readonly: true }],“Json”);

Hello,

Sure, please check sample
scheduler\samples\03_extensions\14_readonly_event.html
Basically pass ‘readonly’ flag set to true.

change

if (this.getEvent(id).user_id!=<?php echo $user_id;?>)

to

var ev = this.getEvent(id); if (ev && ev.user_id!=<?php echo $user_id;?>)
Kind regards,
Ilya

This does not work with repating events, is there a way to make it work?

Hello,

What exactly doesn’t work? Do you want to display readonly form for occurrences of recurring event? If so you can make necessary check in the ‘onBeforeLightbox’ event and set readonly property.

Kind regards,
Ilya

Acctually it’s not the answer that I need. Here is my situation: Everybody can see all the event from the others people. But user only modify the event that was created by them self. So that i put the varaiable user_id in event table. So when user load the scheduler. The event will be set readonly or not depend on their user_id and event.user_id.

Here is my new code! I fixed by your guide. And the new problem is: User cant create new event :slight_smile:

        scheduler.load("<?= base_url();?>booking/getlich/<?= $_POST['product'];?>");
		
		var dp = new dataProcessor("<?= base_url();?>booking/getlich/<?= $_POST['product'];?>");
		dp.init(scheduler);
		function block_readonly(id){
                var ev = this.getEvent(id);
                if (ev && ev.user_id!=<?php echo $user_id;?>)
			    return false;
                if (id) return true;

		}
		scheduler.attachEvent("onBeforeDrag",block_readonly)
		scheduler.attachEvent("onClick",block_readonly)

I was setting readonly in onDblClick instead of onBeforeLightbox. It’s working now. I wish it would show the recurring event details.

I have solved it myselt ^^!

           function allow_own(id){
            var ev = this.getEvent(id);
            return ev.user_id ==<?php echo $user_id;?> ;
           }
           scheduler.attachEvent("onClick",allow_own);
           scheduler.attachEvent("onDblClick",allow_own);
           scheduler.attachEvent("onBeforeDrag",allow_own)