We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

CRUD Operation

Thread ID:

Created:

Updated:

Platform:

Replies:

120003 Aug 21,2015 12:50 PM Aug 26,2015 09:43 AM ASP.NET MVC 3
loading
Tags: Schedule
jarrod
Asked On August 21, 2015 12:50 PM

Hi

Firstly, apologies for the quick message, I am about to duck off to work, and was hoping you might be able to provide a resolution before the weekend begins.

I am trying to write appointments back to the database, but am not having luck with the Batch method on the Controller.  It is just not being called (I put a breakpoint in, but it is never reached)

I have set my view up like this:

@model SyncfusionMvcApplicationCrud.Models.ScheduleModel
 
@{
    ViewBag.Title = "ScheduleFeatures";
}
<h2>ScheduleFeatures</h2>
 
<div>
 
    @(Html.EJ().Schedule("Schedule")
            .Width("100%")
            .Height("525px")
            .TimeZone("UTC +00:00")
            .TimeMode(Syncfusion.JavaScript.TimeMode.Hour24)
            .CurrentDate(DateTime.Now)
            .ShowCurrentTimeIndicator()
            .Views(new List<string>() { "Week" })
            .ShowQuickWindow(true)
            .AppointmentSettings(
                fields => fields.Datasource((IEnumerable<SyncfusionMvcApplicationCrud.Models.DefaultSchedule>)Model.Appointments)
                .Id("Id")
                .Subject("Subject")
                .Description("Description")
                .StartTime("StartTime")
                .EndTime("EndTime")
                .AllDay("AllDay")
                .Recurrence("Recurrence")
                .RecurrenceRule("RecurrenceRule"))
            .ScheduleClientSideEvents(=>
                 e.Create("onCreate")
            )
            .DateFormat("ddd dd/mm/yyyy")
    )
</div>
 
<script type="text/javascript">
 
    function onCreate(args) {
        debugger;
 
        this._dataManager.dataSource.crudUrl = "/Schedule/Batch";
    }
</script>
 
With the CRUD method signature in the controller: 

public JsonResult Batch(EditParams param)

The controller loads the data into my model, rather than using a GetData method on the controller.

Have I missed something?  Do you have an example to illustrate what I am trying to do please?

I have got a working example where the CRUD is working when the schedule is scripted:

$("#Schedule1").ejSchedule({
    width: "100%",
    height: "500px",

But I am hoping I can do it the first way.

Also, am I using the date format correctly?  It doesn't appear to change when I set the format as above. 

Thanks for your help.  I'm off to work now.

Cheers
Jarrod


Velmurugan S [Syncfusion]
Replied On August 24, 2015 06:19 AM

Hi Jarrod,
Thank you for using Syncfusion products.
Please find the following responses for your queries:
Query #1: CRUD operation sample

You can call the Batch action directly without using the client side event “create” and perform the CRUD operation. Please find the following code snippets to meet the requirement “CRUD operation in MVC application”.

<code>
ScheduleFeatures.cshtml:

                @(Html.EJ().Schedule("Schedule1")

        .Width("100%")

        .Height("525px")      

        .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Schedule/GetData").CrudURL("/Schedule/Batch").Adaptor(AdaptorType.UrlAdaptor))

            .Id("Id")

            .Subject("Subject")

            .StartTime("StartTime")

            .EndTime("EndTime")

            .Description("Description")

            .AllDay("AllDay")

            .Recurrence("Recurrence")

            .RecurrenceRule("RecurrenceRule"))

       
)
</code>

Query #2: Date Format in Schedule

We have analyzed the reported scenario with the provided code snippets and found that the necessary dateformat was wrongly passed. Therefore, we suggest you to pass the date format properly to apply the given dateformat to the Syncfusion Controls. Please find the following code snippet to know about how to pass the date format to the Schedule control.
<code>

                @(Html.EJ().Schedule("Schedule1")

        .Width("100%")

        .Height("525px")

.DateFormat("ddd dd/MM/yyyy")    // Here we need to mention the dateformat string with proper cases to apply date format properly (ex: MM for month instead of mm))
</code>

We have prepared the sample with the above code snippets that can be downloaded from the following location. 
http://www.syncfusion.com/downloads/support/forum/120003/ze/SampleScheduleCRUD1148312314

Please let us know if you need further assistance on this.
Regards,
Velmurugan


jarrod
Replied On August 25, 2015 05:31 AM

Thanks very much, the CRUD is working perfectly now.

Now with the DateFormat, I think I may have the wrong end of the stick with it.  What exactly does this property control?  For some reason, I thought that it controlled the format of the date in the column header (I am operating in Week view mode), but now I am not sure I have that correct.   If it does, it is having no affect when I changed it.  If it doesn't control this, is there a way to change the format of the date at the column header?

Cheers
Jarrod


Velmurugan S [Syncfusion]
Replied On August 26, 2015 09:43 AM

Hi Jarrod,

Thanks for you update.
Please find the following responses for your queries:

Query #1: the CRUD is working perfectly now

We are glad to hear that the solution provided by us helped you to meet your requirement.

Query #2: is there a way to change the format of the date at the column header?

You can meet the above mentioned requirement in our Schedule control using our client side events. Please refer the following code snippets that will help you to meet the requirement.

<code>

                @(Html.EJ().Schedule("Schedule1")

        .Width("100%")

        .Height("525px")

        .TimeZone("UTC +00:00")

        .TimeMode(Syncfusion.JavaScript.TimeMode.Hour24)

        .CurrentDate(DateTime.Now)

        .ShowCurrentTimeIndicator()

        .Views(new List<string>() { "Week" })

        .ShowQuickWindow(true)

        .AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Schedule/GetData").CrudURL("/Schedule/Batch").Adaptor(AdaptorType.UrlAdaptor))

            .Id("Id")

            .Subject("Subject")

            .StartTime("StartTime")

            .EndTime("EndTime")

            .Description("Description")

            .AllDay("AllDay")

            .Recurrence("Recurrence")

            .RecurrenceRule("RecurrenceRule"))

        .DateFormat("ddd dd/MM/yyyy")    // Here we need to mention the with proper cases to apply date format properly (ex: MM for month instead of mm)

        .ScheduleClientSideEvents(evt =>evt.Create("onCreate").ActionComplete("onCreate"))



)


<script>

    function onCreate() {  // The following code snippet is used to display the column header date in specified format

        var obj = $("#Schedule1").data("ejSchedule");

        if (obj.currentView() != "month") {

            for (var i = 0; i < obj.dateRender.length; i++) {

                var temp = Globalize.format(new Date(obj.dateRender[i]), obj.model.dateFormat);

                obj.element.find(".e-headerdaydisplay")[i].innerHTML = temp;

            }

        }

    }
</script>

</code>
We have modified the sample with the above code snippets, which can be downloaded from the following location.
http://www.syncfusion.com/downloads/support/forum/120003/ze/SampleScheduleCRUD1562197851

Please let us know if it helps and if you need any further assistance on this.
Regards,
Velmurugan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;