event data validation

Hi

I am developing small mobile calendar application for my project purpose.

I want to validate the event details before saving the event. To understand this funtionality, I followed below url to do the validation but not able to do the same.

viewtopic.php?f=24&t=21370&p=68464&hilit=validation#p68464

–Pavan

Hi,

this solution works in 3.5 too. If the event handler returns false, the request won’t be sent to the server.

Could you provide the example of your code that doesn’t work ?

As you said, it is validating the data but my issue is, when validation fails, the event window should not close until user corrects the same or click on cancel button. But the event window is closing and navigating back to calendar page even after validation fails and empty event is created on the calendar. Which is not correct. Please let me know how to stop closing of the event window if validation fails.

–pavan

Which validation are you going to use : client or server ?

In case of client-side validation you may add rules into form_rules collection. For example save only events with non-empty “text” you may add the following rule:

scheduler.config.form_rules[“text”] = function(value,obj){
return value
}

I have the same query/issue as Pavan - how can the mobile scheduler be configured such that, if validation fails (either client-side or server-side), the edit event window stays open, so that the user can fix the issues (e.g. select a time that doesn’t conflict)?

I have already posted the solutions for server-side validation - you may define rules (validation functions) for the form fields. If the function does not return a positive value, validation fails.

There is not a ready solution to process error callback. If the form is successfully validated on client, it will be closed. To reopen it you may use the following approach:

$$(“scheduler”).$$(“form”).show();

When the DataProcessor receives “error” or “invalid” response, it fires “onDBError” event:

dhx.dp($$("scheduler")).attachEvent("onDBError",function(callbackData,requestData){ /* your code here */ return false })

Thanks Alexandra. I was about to post an update: previously I was using onBeforeDataSend but after doing some more reading I understood your previous response properly, and was able to do validation in a way that keeps the form open, by setting setting scheduler.config.form_rules as you described.

Thanks for that extra code snippet re. making the form show again, that’s a good point.

However, being a typical (potential) customer I’m always wanting more :wink:, and the challenges I’m facing now are:

a) Displaying a meaningful message to the user when my validation rule fails (e.g. explaining that the event details conflict with an existing event).

b) Enhancing the business rules so that there are three levels of validation i.e. the event does one of:
i) Gets created
ii) Fails validation (e.g. conflicts)
iii) Gives the user an ‘Are you sure?’ message (e.g. event is adjacent)

I’m evaluating building my app (which has desktop and mobile views) using Scheduler .NET MVC and I’ve started the mobile side by trying to ‘bolt on’ the mobile version of the scheduler as a component. As I get to grips with the mobile and desktop versions of scheduler (somewhat slowly, since this is my first .Net MVC app as I transition away from Flex) I’m reaching the conclusion that rather than use the mobile scheduler component, I should define the calendar and each form/dialogue as separates views rendered using Touch (via Razor), and manage the model & controllers in MVC. Does that sound right, or am I still missing something?

I must admit that I’m finding it a lot harder than I thought it would be to piece together what I need to do to have a scheduler app that has desktop and mobile views using a .NET MVC implementation - if there are any tutorials or examples that do show the whole lot working together, please do point me in the right direction. If there isn’t, I’ll post up a summary of what I do when I get everything working if and when I get that far.

Hello,

Displaying a meaningful message to the user when my validation rule fails (e.g. explaining that the event details conflict with an existing event).

Form triggers onValidationError event when validation rule fails:

$$(“scheduler”).$$("").attachEvent(“onValidationError”,function(key,obj){
//your code here
return true
});

If the event return true, the field will be marked with “invalid” className

Form triggers onValidationSuccess event in case of correct validation.

I’m reaching the conclusion that rather than use the mobile scheduler component, I should define the calendar and each form/dialogue as separates views rendered using Touch (via Razor), and manage the model & controllers in MVC. Does that sound right, or am I still missing something?

Scheduler creates all components by itself. Please see Mobile Scheduler samples.

Unfortunately, there are not ready samples and tutorials for Mobile Scheduler using .NET MVC implementation. However, Mobile Scheduler may load data in the same format as Desktop and data saving is also the same. So, you can use the same scripts data generation and saving.

Thanks for the further info. I’m going to experiment with creating separate Touch views in .net MVC instead of using the whole Touch scheduler component (whilst using the scheduler source code to draw from) to see if that is effective at implementing the functionality I am after.