Hi,
I have added a category to the lightbox in the controller for the page,
[code]var check = new LightboxRadio(“category”, “Category”);
foreach (var db_EventCat in db_EventCats)
{
check.AddOption(new LightboxSelectOption(db_EventCat.Cat_Id, db_EventCat.Category));
}[/code]
When i save the event, the relevent data is passed back and i am able to handle this, the data is also retrieved. Hoever, the saved category is not displayed when i open the event.
Code for saving
case DataActionTypes.Insert:
myev = new Event();
myev.event_Cat = int.Parse(actionValues["category"]);
myev.start_date = DateTime.ParseExact(actionValues["start_date"], "g", CultureInfo.CurrentCulture);
myev.end_date = DateTime.ParseExact(actionValues["end_date"], "g", CultureInfo.CurrentCulture);
myev.text = actionValues["text"];
data.Events.InsertOnSubmit(myev);
break;
Code for getting the data to be displayed…
[code]public ContentResult Data()
{
var data = new SchedulerAjaxData((new ScheduledActivitiesDataContext()).Events);
data.DateFormat = "%d/%m/%Y %H:%i";
return data;
}[/code]
What needs to be changed so that the category is entered into lightbox for savewd events?
Hello,
by default control is mapped to event property with the same name, so you need to either change control’s name, or explicitely map it to the ‘event_Cat’ property
var check = new LightboxRadio("event_Cat", "Category");
OR
var check = new LightboxRadio("category", "Category");
check.MapTo = "event_Cat"
and in the save action:
myev.event_Cat = int.Parse(actionValues["event_Cat"]);
Thank you,
One last question…
How would i customise the control to show different colours for different events? Is there a tutorial or location i should look at for this?
Regards
Event color is defined by
myev.color
myev.textColor
you can add radio or select, and map it to the one of those properties
Is there a way i can map
var check = new LightboxRadio("category", "Category");
check.MapTo = "event_Cat"
to myev.color ?
What i am trying to achieve is dynmic assignment of the color based on the category selected…
So if i have…
// Add event categories
var check = new LightboxRadio("event_Cat", "Category");
foreach (var db_EventCat in db_EventCats)
{
check.AddOption(new LightboxSelectOption(db_EventCat.Cat_Id, db_EventCat.Category));
}
sched.Lightbox.Add(check);
Which contains and id for the category and the outputted text name for it, how do i also map a colour to this for displaying?
Hello,
lightbox control can be mapped to one property only, you can map it to ‘event_Cat’ property,
and update event color each time this property is updated in the db -
scheduler configuration
...
var check = new LightboxRadio("category", "Category");
check.MapTo = "event_Cat";
...
scheduler.Data.DataProcessor.UpdateFieldsAfterSave = true;
and in save action, instead of
return (new AjaxSaveResponse(action));
will be
string color = <define color from category id somehow>;
var result = new AjaxSaveResponse(action);
result.UpdateField("textColor", color);
return result;
This will work when saving, but how do i get it to set the event colour when loading from the database?
public ContentResult Data()
{
var data = new SchedulerAjaxData((new ScheduledActivitiesDataContext()).Events);
data.DateFormat = "%d/%m/%Y %H:%i";
return data;
}
it will require some js coding,
var colors = {
//render "categoryId":"color", pairs
};
scheduler.attachEvent("onEventLoading", function(ev){
ev.textColor = colors[ev.event_Cat];
return true;
});
- add this code after scheduler.Render() call
or you may just add textColor property to your model and assign color before pass events to SchedulerAjaxData’s constructor