开发者

How to validate appointment before RadScheduler inserting

开发者 https://www.devze.com 2023-04-12 19:40 出处:网络
I have a problem with RadScheduler. I need to validate double clicked time slot for availability before insert form opens. I using advanced insert form. Unfortunately its no OnAppointmentInserting or

I have a problem with RadScheduler. I need to validate double clicked time slot for availability before insert form opens. I using advanced insert form. Unfortunately its no OnAppointmentInserting or like event like this. I found OnClientAppointmentInserting event, and i can use it for validation, but i can not continue to insert form if validation is correct. Following the code i use for client side validation, but its no way to show insert form after validation:

function beforeInserting(s, e) {
        var url = '';
        var requestUrl = window.location.href.toLowerCase();
        if (requestUrl.indexOf('/views/') != -1)
            url = requestUrl.substring(0, requestUrl.indexOf('/views/')) + '/jobservice.svc/IsTimeAvailable?userId=0';
        e.set_cancel(true);
        var app = e.get_targetSlot();

        $.ajax({
            url: url,
            accepts: 'application/json, text/javascript, */*',
            cache: false,
            success: function (r) {
                if (r != '') {
                    alert(r);
                    return;
                }
                else 开发者_运维知识库{
                    var scheduler = $find("<%= rdJobScheduler.ClientID %>");
                    var newApp = new Telerik.Web.UI.SchedulerAppointment();

                    newApp.set_start(app.get_startTime());
                    newApp.set_end(app.get_endTime());

                    // This is not working properly it just send OnInserted event to server
                    // scheduler.insertAppointment(newApp);
                }
            },
            error: function (err, text, xhr) {
                alert(text);
            }
        });
    }


Please take a look at this Knowledge Base article of Telerik to see how to prevent inserting of appointment. In their case only if the subject of the appointment is empty - you cannot insert the appointment. You can use your own validation instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号