search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Change row color when event drag

Asked by Vatthanachai
7 years ago.

Hi, I need some help. Did the Daypilot can be change the resource background color when drag the event and the event resource id are math the resource row id?

Comment posted by Vatthanachai
7 years ago.

I mean to the Daypilot scheduler mvc.
Thanks

Answer posted by Dan Letecky [DayPilot]
7 years ago.

You can highlight the original row using onEventMoving event handler. In the ASP.NET MVC you can set this event handler using EventMovingJavaScript property:
https://doc.daypilot.org/scheduler/event-moving-customization/

See also:
https://api.daypilot.org/daypilot-scheduler-oneventmoving/

Example:

MVC View:
@Html.DayPilotScheduler("dp", new DayPilotSchedulerConfig {
    BackendUrl = Url.Action("Backend", "Scheduler"),
    // ...
    EventMovingJavaScript = "onEventMoving(args)"
})
JavaScript:
function onEventMoving(args) {
    dp.rows.all().forEach(function(row) {
        row.removeClass("highlighted");
    });
    if (args.e.resource() === args.resource) {
        args.row.addClass("highlighted");
    }
}

This will add "highlighted" CSS class to the header of the original row when the event shadow is over that row. You'll need to clear the CSS class on drop (use EventMoveJavaScript or a global mouseup event):

    dp.rows.all().forEach(function(row) {
        row.removeClass("highlighted");
    });
Comment posted by Vatthanachai
7 years ago.

Thank you very much, I'll try it.

Comment posted by Vatthanachai
7 years ago.

It work, but it work only when i drag event hover to correct row only.
If I drag event to scheduler it can highlight all correct rows.

Example :
When I drag the Asphat item to scheduler, The Asphat rows will be highlight.

<a href="http://www.mx7.com/view2/zubb9sX4ZOMRHi4b" target="_blank"><img border="0" src="http://www.mx7.com/i/1d5/hyupec.png" /></a>

Comment posted by Vatthanachai
7 years ago.

Now I can do it. Thank you very much.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.