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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Call controller and open custom modal view, when cell was clicked

Thread ID:

Created:

Updated:

Platform:

Replies:

143317 Mar 13,2019 08:39 PM UTC Mar 15,2019 09:26 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Schedule
Jorge
Asked On March 13, 2019 08:39 PM UTC

Hello, I am working on a MVC 5 web application with Schedule for hotel reservations.

I need, when I click on a cell, if it is empty, call the controller (Create) and if it has an event, call the controller (Details), and then return a modal window, with the result of the view.

I also need to pass the data of the cell where it was clicked.

For example:

    function OnCellClick (args) {

         args.cancel = true;

         $ .ajax ({
             type: 'GET',
             url: '@ Url.Action ("Create", "Reservation")',
             contentType: "application / json; charset = utf-8",
             dataType: "json",
             data: { args: args },
             success: function () {
                 $ ('# modal_view_create'). show ();
             },
             error: function () {
                 alert ('Error');
         });

   }

If it is not possible to call a controller, at least how can I open a modal window.

Thanks in advance.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On March 15, 2019 09:26 AM UTC

Hi Jorge, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the sample to show different editors on cell and event click. In the below sample, standard editor is prevented with in CellClick and EventClick events and custom editor is showed using openEditor public method and PopupOpen event. 
 
@Html.EJS().Schedule("schedule").SelectedDate(new DateTime(2018, 2, 15)).Width("100%").Height("550px").EventSettings(e => e.DataSource(ViewBag.appointments)).PopupOpen("onPopupOpen").EventClick("onEventClick").CellClick("onCellClick").Render() 
 
function onCellClick(args) { 
        args.cancel = true; 
        this.editorTemplate = "#CellEditorTemplate"; 
        this.dataBind(); 
        this.openEditor(this.activeCellsData, 'Add'); 
    } 
    function onEventClick(args) { 
        args.cancel = true; 
        this.editorTemplate = "#EventEditorTemplate"; 
        this.dataBind(); 
        this.openEditor(this.activeEventData.event, 'Save'); 
    } 
    function onPopupOpen(args) { 
        if (args.type === 'Editor') { 
            var statusElement = args.element.querySelector('#EventType'); 
            if (!ej.base.isNullOrUndefined(statusElement)) { 
                if (!statusElement.classList.contains('e-dropdownlist')) { 
                    var dropDownListObject = new ej.dropdowns.DropDownList({ 
                        placeholder: 'Select a status', value: statusElement.value, 
                        dataSource: ['New', 'Requested', 'Confirmed'] 
                    }); 
                    dropDownListObject.appendTo(statusElement); 
                    statusElement.setAttribute('name', 'EventType'); 
                } 
            } 
            var startElement = args.element.querySelector('#StartTime'); 
            if (!startElement.classList.contains('e-datetimepicker')) { 
                new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date() }, startElement); 
            } 
            var endElement = args.element.querySelector('#EndTime'); 
            if (!endElement.classList.contains('e-datetimepicker')) { 
                new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date() }, endElement); 
            } 
        } 
    } 
 
Regards, 
Karthi 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon