Lightbox dropdown values on edit/details

Hi,

I have added 2 new fields to the Lightbox as dropdowns (lightboxselect). This is working well - but I want to set the values of the dropdown boxes as per the details relevant to the chosen appointment (at the moment they always show the default values).

How do you set dropdown values when the user double clicks on the appointment in the calendar or opens an appointment in edit mode?

Note: I am using ASP.NET webforms - but can translate from MVC - whichever is easiest to sort the issue out.

Thansk for your help.
Cheers,
Brett

In js version -it is controlled by the map_to value of lightbox section, when existing event shown - value from map_to property is used as selected value for the select box.

So if you have unitId property in db and in list of connector fields, you can use

… map_to:“unitId”… while configuring lightbox.

docs.dhtmlx.com/doku.php?id=dhtm … o_the_form

The same for .Net
scheduler-net.com/docs/lightbox. … n_controls

var check = new LightboxCheckbox("highlighting", "Important");

First parameter is name of field in dataset which will be used as selected value for select box.

Thanks.

I do already have the dropdown lists populating with data and it does save to the database. However when I open an existing record, it does not set the value of the dropdown box to the saved value.

I will try a few other things.

Still cannot get the lightbox dropdowns to set the value from the record. I have ensure that the fields match the names exactly, including letter case. Here is my code when the page loads. Note that I am looping through AddOption from a LINQ result set.

The dropdowns populate fine. I am also noticing that when the original save occurs, the dropdown values are saved correctly, however during an Update, the dropdown values end up null.

[i] protected void Page_Load(object sender, EventArgs e)
{
var dc = new Old_App_Code.FullSpectrumDataContext();

        this.Scheduler = new DHXScheduler();

        Scheduler.InitialDate = DateTime.Now; // new DateTime(2011, 11, 24);

        //add event list (ones that have not expired
        LightboxSelect lbsEvent = new LightboxSelect("EventID", "Event Name");
        var resEvents = from a in new Old_App_Code.FullSpectrumDataContext().Events
                        //where a.EndDate >= DateTime.Now &&
                        //       a.StartDate <= DateTime.Now
                        select new { a.EventID, a.EventName };

        

        foreach (var res in resEvents)
        {
            lbsEvent.AddOption(new LightboxSelectOption(res.EventID, res.EventName));
        }

        //add practitioner list
        LightboxSelect lbsPractitioner = new LightboxSelect("PractitionerContactID", "Practitioner Name");
        var resPractitioner = from a in new Old_App_Code.FullSpectrumDataContext().Contacts
                              where a.ContactTypeID == 3
                              orderby a.FirstName
                              select new { a.ContactID, a.FirstName, a.LastName };

        foreach (var res in resPractitioner)
        {
            lbsPractitioner.AddOption(new LightboxSelectOption(res.ContactID, res.FirstName + " " + res.LastName));
        }


        //add client list
        LightboxSelect lbsCustomer = new LightboxSelect("CustomerContactID", "Customer Name");
        var resCustomer = from a in new Old_App_Code.FullSpectrumDataContext().Contacts
                          where a.ContactTypeID != 3
                          orderby a.FirstName
                          select new { a.ContactID, a.FirstName, a.LastName };

        foreach (var res in resCustomer)
        {
            lbsCustomer.AddOption(new LightboxSelectOption(res.ContactID, res.FirstName + " " + res.LastName));
        }


        Scheduler.Lightbox.AddDefaults();
        Scheduler.Lightbox.Items.Insert(0, lbsEvent);
        Scheduler.Lightbox.Items.Insert(1, lbsCustomer);
        Scheduler.Lightbox.Items.Insert(2, lbsPractitioner);

        
        Scheduler.Config.first_hour = 8;
        Scheduler.Config.last_hour = 19;
        Scheduler.Config.time_step = 30;
        Scheduler.Config.limit_time_select = true;
        //Scheduler.Config.xml_date = "%Y-%m-%d %H=>%i";
        Scheduler.Config.api_date = "%Y-%m-%d %H:%i";

        Scheduler.DataAction = "Data.ashx";
        Scheduler.SaveAction = "Save.ashx";
        Scheduler.LoadData = true;
        Scheduler.Data.Loader.PreventCache();
        Scheduler.EnableDataprocessor = true;
       
    }[/i]

Hello,
your code seems right to me. If names of the controls are the same as properties of the data objects, then related values should be selected.
Can you attach or send me in PM small demo project where problem can be tested?

btw, are there any changes if you fill dropdowns with AddOptions method with the code like following?[code]var resPractitioner = from a in new Old_App_Code.FullSpectrumDataContext().Contacts
where a.ContactTypeID == 3
orderby a.FirstName
select new { key = a.ContactID, label = a.FirstName +" "+ a.LastName };

lbsCustomer.AddOptions(resPractitioner.ToList());[/code]

Hi I think I have figured it out (workaround) - isolated to the Update helper:

DHXEventsHelper.Update(updated, changedEvent, new List() { “BookingID” });

For some reason the values in changedEvent were not being passed to the updated object. I have commented out the above call and have created my own mapping of fields;

updated.BookingDate=changedEvent.BookingDate;
updated.StartTime=changedEvent.StartTime;
updated.EndTime=changedEvent.EndTime;

What I did notice is that the updated object had values for foreign key fields, whereas the changedEvent had the key id fields, but not the ‘lookup’ values. This seems like a bit of a LINQ issue if your data is in hierarchy. I wonder if you can tell an object from the data context to temporarily ignore the lookups for foreign keys…

Thanks for your attention. Working well now!

(PS your forum website is very slow. Using from Australia - takes pages forever to post back)