I have a custom LightBox control, a readonly label showing the user who inserted/modified the event.
server side:
var labelUser = new LightboxLabel("userLabel", "User");
labelUser.MapTo = "userLabel";
sched.Lightbox.Add(labelUUser);
public class LightboxLabel : DHTMLX.Scheduler.Controls.LightboxField
{
public LightboxLabel(string name, string text)
: base(name)
{
this.Type = "label";
this.Label = text;
}
}
client-side:
scheduler.form_blocks["label"] = {
render: function (sns) {
return "<div class=\"labelLightBox\">user</div>";
},
set_value: function (node, value, ev) {
node.childNodes[0].nodeValue = ev.userLabel;
},
get_value: function (node, ev) {
return node.childNodes[0].nodeValue = ev.userLabel
},
focus: function (node) { }
};
I bind data like this:
var events = from ln in context.UsersToAgendes
join e in context.Events on ln.AgendaId equals e.AgendaId
join a in context.Agendes on e.AgendaId equals a.key
join users in context.aspnet_Users on e.user_id equals users.key
where ln.UserId == (Guid)Membership.GetUser().ProviderUserKey
select new EventExtended()
{
AgendaId = e.AgendaId,
caseCode = e.caseCode,
color = e.color,
end_date = e.end_date,
event_length = e.event_length,
event_pid = e.event_pid,
id = e.id,
rec_type = e.rec_type,
start_date = e.start_date,
text = e.text,
user_id = e.user_id,
userLabel = users.label,
nameAgenda = a.label
};
As you can see my user label is retrieved by another table “aspnet_Users” which is joined to the event table which contains the user_id.
To save user I do something like this:
var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
changedEvent.user_id = (Guid)Membership.GetUser().ProviderUserKey;
My problem is that client-side is not updating the label with the new user on all succeeding updates.
The event "get_value: " has always the “ev.userLabel” equals to undefined
Javascript is triggered before server-side saving, so the property with the new user value is not validated.
How can I update that so my event has the correct and updated user??
I have no problem server side, the data is always saved correctly because I retrieve the user whenever I hit the save button.