Not all items from lightbox are being posted to controller

Hi

I have looked around and yours is the best scheduler control i have come across in terms of features but i am struggling to get it working. I am also running this on top of Orchard CMS which also presents a hole lot of its own issues.
I am having trouble getting all the form data from my custom Light box control to be posted to the controller, Will i debug my code i can see the values being set in the getValues() method but in the actual post they don’t exist, the specific field is a hidden input, then also how would i post values from ListBoxes in some sort of array.

I hope i am not being too vague.

Kind Regards
Paul

Normally, when custom lighbox is closing, code need to set values from inputs in form to the event object, it really doesn’t matter which type of inputs you are using, you can set any values to any properties of events - all events properties will be sent to the server side and will be available during data saving.

scheduler.getEvent(id).any_name = any_value;

Hi, Thanks for your reply, however i am still lost, i am getting a

here is my code if you can please look at it and tell me where i am going wrong i would really appreciate it.

LightboxControl.cshtml

[code]@model Comair.OT.Models.DTO.ScheduleDTO

@{
// Layout = null;
Script.Require(“KendoUI”).AtHead();

}

@using (Html.BeginFormAntiForgeryPost("Save"))
{                

    @Html.HiddenFor(m => m.ScheduleId)
    @Html.HiddenFor(m => m.ScheduledFor.Id)  
    
    <table>
        <tr>
        <td>Scheduled For</td>
        <td>@(Html.Kendo().ComboBox()
                .Name("ScheduledForList")
                .Filter(FilterType.Contains)
                .Placeholder("Select Scheduled For")
                .DataTextField("Name")
                .DataValueField("EntityId")
                .Events(events => events.Change("scheduledFor"))
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetScheduleForList", "SchedulerAjax");
                    });

                })
         )</td>           
            <td></td>
        </tr>
    <tr>
        <td style="vertical-align:top">Trainer</td> 
        <td style="vertical-align:top">@(Html.Kendo().ComboBox()
                .Name("TrainerList")
                .HtmlAttributes(new { style = "width:200px" })
                .Filter(FilterType.Contains)
                .Placeholder("--Select Trainer--")
                .DataTextField("DisplayName")
                .DataValueField("ProfileId")
                .Events(events => events.Change("addTrainer"))
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetTrainers", "SchedulerAjax");
                    });
                })
        )</td>

        <td>@Html.ListBoxFor(m => m.Trainers, new SelectList(new[] { "" }), new { style="width: 200px"})</td>   
                
    </tr>
    <tr>
        <td style="vertical-align:top">Students</td>
        <td style="vertical-align:top">@(Html.Kendo().ComboBox()
                .Name("StudentList")
                .Filter("contains")
                .Placeholder("--Select Student--")
                .DataTextField("DisplayName")
                .DataValueField("ProfileId")
                .Events(events => events.Change("addStudent"))
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetStudents", "SchedulerAjax");
                    });
                })

         )</td>

        <td align="left">@Html.ListBoxFor(m => m.Students, new SelectList(new[] {""}), new { style="width: 200px"})</td> 
                
    </tr>
    <tr>
        <td>Location</td>
        <td>@(Html.Kendo().ComboBox()
                .Name("LocationList")
                .Filter("contains")
                .Placeholder("--Select Location--")
                .DataTextField("DisplayName")
                .DataValueField("ProfileId")
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetLocations", "SchedulerAjax");
                    });
                })

        )</td>
        <td></td>
    </tr>
    <tr>
        <td>Subject</td>
        <td colspan="2">@Html.TextBoxFor(m => m.ScheduleSubject, new { style = "width: 440px" })</td>
    </tr>
    <tr>
        <td style="vertical-align:top">Notes</td>
        <td colspan="2">@Html.TextAreaFor(m => m.Notes, 5, 52, null)</td>
    </tr>    
    <tr>
        <td colspan="3">From
        @Html.TextBoxFor(m => m.start_date, new { @class = "scheduleDate", width = "100px" })
        To
        @Html.TextBoxFor(m => m.end_date, new { @class = "scheduleDate", width = "100px" })</td>
        <td></td>
    </tr>
    </table>
    <p>
        <input type="button" value="Save" onclick="lightbox.save()" />
        <input type="button" onclick="lightbox.close()/* helper-method, only available in custom lightbox */" value="Close" />
        <input type="submit" name="actionButton" value="Delete" />
    </p>
}
[/code]

SchedulerController

[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Comair.OT.Business;
using DHTMLX.Scheduler;
using DHTMLX.Common;
using DHTMLX.Scheduler.Data;
using Orchard.Security;
using Orchard.Themes;
using Comair.OT.Models.DTO;
using System.Globalization;
using DHTMLX.Scheduler.Controls;

namespace Comair.OT.Admin.Controllers.Scheduler
{
[Themed]
public class SchedulerController : BaseController
{
public SchedulerController(IAuthenticationService authenticationService)
: base(authenticationService)
{

    }
    //
    // GET: /Scheduler/
    public ActionResult Index()
    {
        var scheduler = new DHXScheduler(this);
        scheduler.Codebase = Url.Content("~/Modules/Comair.OT.Admin/Scripts/dhtmlxScheduler_debug");
        //scheduler.SaveAction = Url.Content("~/SchedulerAjax/Save");
        //scheduler.DataAction = Url.Content("scheduleData");
        scheduler.Skin = DHXScheduler.Skins.Terrace;
        scheduler.Config.multi_day = true;//render multiday events
        scheduler.LoadData = true;
        scheduler.EnableDataprocessor = true;
        scheduler.Views.Add(new AgendaView());
        
        //view, width, height
        var box = scheduler.Lightbox.SetExternalLightboxForm("SchedulerAjax/LightboxControl", 585, 450);
        //css class to be applied to the form
        box.ClassName = "custom_lightbox";
        scheduler.InitialDate = DateTime.Now;


        return View(scheduler);
    }

    public ActionResult Data()
    {
        var data = Schedules.ReadScheduleDTOList(); // new SchedulerAjaxData(Schedules.ReadSchedules());

        return new SchedulerAjaxData(data);
    }
    public ContentResult Save(long? id, Models.DTO.ScheduleDTO schedule, FormCollection actionValues)
    {
        var action = new DataAction(actionValues);
        var changedEvent = (Models.DTO.ScheduleDTO)DHXEventsHelper.Bind(typeof(Models.DTO.ScheduleDTO), actionValues);
        if (action.Type != DataActionTypes.Error)
        {
            //process resize, d'n'd operations...
            //    return NativeSave(changedEvent, actionValues);
            return CustomSave(schedule, actionValues);

        }
        else
        {
            schedule.StartDate = DateTime.ParseExact(actionValues["start_date"], "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
            schedule.EndDate = DateTime.ParseExact(actionValues["end_date"], "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
            //custom form operation
            return CustomSave(schedule, actionValues);
        }

        return null;
    }

    public ContentResult CustomSave(Models.DTO.ScheduleDTO schedule, FormCollection actionValues)
    {

        var action = new DataAction(DataActionTypes.Update, schedule.ScheduleId, schedule.ScheduleId);
        
        foreach (var s in actionValues["Students"].Split(','))
        {
            if (s != string.Empty)
                schedule.Students.Add(new ProfileDTO() { ProfileId = Int16.Parse(s) });
        }

        foreach (var s in actionValues["Trainers"].Split(','))
        {
            if (s != string.Empty)
                schedule.Trainers.Add(new ProfileDTO() { ProfileId = Int16.Parse(s) });
        }

        //schedule.ScheduledFor = new EntityLookup() { Id = Convert.ToInt64(actionValues["ScheduledFor"]) };
        schedule.ScheduleTypeId = (int)Filters.Enums.ScheduleTypeEnum.AssessmentSchedule;
        schedule.StatusId = 4;


        if (actionValues["actionButton"] != null)
        {

            try
            {
                if (actionValues["actionButton"] == "Save")
                {

                    if (Schedules.ReadSchedule(action.SourceId) != null && action.SourceId != 0)
                    {
                        //                    var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        //                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                    }
                    else
                    {
                        action.Type = DataActionTypes.Insert;
                        schedule = Schedules.CreateScheduleFromDTO(schedule, UserId);
                    }
                }
                else if (actionValues["actionButton"] == "Delete")
                {
                    //                action.Type = DataActionTypes.Delete;
                    //                changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    //                data.Events.DeleteOnSubmit(changedEvent);
                }

            }

            catch
            {
                action.Type = DataActionTypes.Error;
            }
        }
        else
        {
            action.Type = DataActionTypes.Error;
        }

        action.TargetId = schedule.id;
        return (new AjaxSaveResponse(action)); 
        //return (new SchedulerFormResponseScript(action, schedule));


    }

}
}
[/code]

SchedulerAjaxController (i use this as i want to avoid the theming for the lightbox which is implimented on the schdulerController, this is an Orchard Theme)

[code]using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Comair.OT.Business;
using Comair.OT.Models.DTO;
using DHTMLX.Common;
using DHTMLX.Scheduler.Data;
using Orchard.Security;

namespace Comair.OT.Admin.Controllers.Scheduler
{
public class SchedulerAjaxController : BaseController
{

   public SchedulerAjaxController(IAuthenticationService authenticationService)
        : base(authenticationService)
    {

        
    }

    public ActionResult LightboxControl(ScheduleDTO schedule)
    {
        var current = Schedules.ReadScheduleDTO(schedule.ScheduleId);

        if (current == null)
            current = schedule;

        return View("Scheduler/LightboxControl", current);
    }

    #region Helper metods

    public JsonResult GetTrainers()
    {
        return Json(Helpers.ListHelpers.ProfileList(Filters.Enums.ProfileTypeEnum.Trainer), JsonRequestBehavior.AllowGet);
    }

    public JsonResult GetStudents()
    {
        return Json(Helpers.ListHelpers.ProfileList(Filters.Enums.ProfileTypeEnum.Student), JsonRequestBehavior.AllowGet);
    }

    public JsonResult GetScheduleForList()
    {
        return Json(Helpers.ListHelpers.EntityListForScheduleDTO(), JsonRequestBehavior.AllowGet);
    }

    public JsonResult GetLocations()
    {
        return Json(Helpers.ListHelpers.LocationList(Filters.Enums.EntityTypeCategoryEnum.Location), JsonRequestBehavior.AllowGet);
    }

    #endregion

}

}
[/code]

Model

[code]using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Comair.OT.Models;

namespace Comair.OT.Models.DTO
{
public partial class ScheduleDTO
{

    public virtual long ScheduleId { get; set; }
    public virtual int ScheduleTypeId { get; set; }
    public virtual long EstablishmentId { get; set; }
    public virtual long DepartmentId { get; set; }
    [Required]
    public virtual EntityLookup ScheduledFor { get; set; }
    public virtual List<ProfileDTO> Trainers { get; set; }
    [Required]
    public virtual List<ProfileDTO> Students { get; set; }
    public virtual DateTime StartDate { get; set; }
    public virtual DateTime EndDate { get; set; }
    [Required]
    public virtual string ScheduleSubject { get; set; }
    [Required]
    public virtual string Notes { get; set; }
    public virtual List<EntityLookup> ScheduledItems { get; set; }
    public virtual EntityLookup Location { get; set; }
    public virtual int StatusId { get; set; }

    public long id { get { return ScheduleId; } }
    public DateTime start_date { get { return StartDate; } set {this.StartDate = value;} }
    public DateTime end_date { get { return EndDate; } set { this.EndDate = value; } }
    public string text { get { return ScheduleSubject; } set { this.ScheduleSubject = value; } }
    public string details { get { return Notes; } set { this.Notes = value; } }



}

}[/code]

Thanks so much for your time.

Paul

Try adding @Html.AntiForgeryToken() in the form
If nothing helps - please attach the project so I could test it