Hi
I'm working with Gantt control but I'm stuck on 2 things. I need to handle events like:
- Change progress of a task
- Delete key pressed on (in order to cancel deleting process)
I'd be grateful for your help because I spent a few hours already on that and didn't find the solution.
Thanks,
Maciek
14 Answers, 1 is accepted
The Gantt exposes server events, which fire when a task is edited (for example when its progress is changed) or deleted. Currently on the client events equivalent to the server-side TaskUpdate and TaskDelete events are not exposed. We would suggest logging a feature request in our Feedback Portal and voting for it.
Regards,
Ivan Danchev
Telerik by Progress
Thanks for the answer,
is there any possible workaround for progress changed? I tried to catch dragstart and dragend events of the small triangle but they weren't fired. Any ideas?
You could try the following workaround that uses jQuery in order to detect the progress handle drag:
function
pageLoad() {
var
$ = $telerik.$;
var
isDragged =
false
;
$(
".rgtTasks"
).mouseup(
function
() {
var
wasDragged = isDragged;
isDragged =
false
;
if
(wasDragged) {
//custom code...
}
})
$(
".rgtDragHanle"
).mousedown(
function
() {
isDragged =
false
;
}).mousemove(
function
() {
isDragged =
true
;
}).mouseup(
function
() {
var
wasDragged = isDragged;
isDragged =
false
;
if
(wasDragged) {
//custom code...
}
});
}
Regards,
Ivan Danchev
Telerik by Progress
Thanks for that Ivan,
I'll try it out for sure and let you know if it helped :)
Thanks Ivan,
your code helped me perfectly, I had only to add listener to page in case when mouseup is triggered outside from slider.
Could you maybe help me with my second question too? I've catched the delete key pressed event and returned false but the deleting process wasn't interrupted.
Regards,
Maciek
The confirmation window that pops up when you select a task and press the Delete key can be closed by clicking its cancel button with the help of jQuery. This will prevent the deletion confirmation window from appearing, thus preventing the task deletion. For this to work the Gantt's DisplayDeleteConfirmation property must be set to "true".
​
$(
'.RadGantt'
).keydown(
function
(event) {
if
(event.keyCode == 46) {
$(
".k-gantt-cancel"
).click();
}
});
Regards,
Ivan Danchev
Telerik by Progress
Thanks Ivan for the response,
unfortunatelly it's not working. The event gets fired, the keycode is 46 and even $(".k-gantt-cancel") collection length is 1 but still, the windows pops up.
At my end it works correctly in Chrome, Firefox and IE11. I attached a sample project you could run and check the behavior in, on pressing Delete. Telerik dlls are not included in the bin folder in order not to exceed the maximum allowed attachment size.
Regards,
Ivan Danchev
Telerik by Progress
Hi Ivan,
thanks for your answer, unfortunately last 2 weeks I had to focus on something else and didn't look at your example. Now the link isn't active anymore, could you please upload it again?
Indeed the link has become invalid. I re-attached the .zip file.
Regards,
Ivan Danchev
Telerik by Progress
It seems we have a temporary issue with the forum attachments so I'll post the content of the aspx, aspx.cs and xml files here:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<
html
xmlns
=
'http://www.w3.org/1999/xhtml'
>
<
head
id
=
"Head1"
runat
=
"server"
>
<
title
>Telerik ASP.NET Example</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
div
class
=
"container"
>
<
telerik:RadGantt
runat
=
"server"
ID
=
"RadGantt1"
AutoGenerateColumns
=
"true"
Skin
=
"Default"
DisplayDeleteConfirmation
=
"true"
Height
=
"450px"
SelectedView
=
"MonthView"
AllowColumnResize
=
"true"
/>
</
div
>
<
script
>
function pageLoad() {
var $ = $telerik.$;
$('.RadGantt').keydown(function (event) {
if (event.keyCode == 46) {
$(".k-gantt-cancel").click();
}
});
}
</
script
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Configuration;
using
System.Web.Security;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
private
const
string
ProviderSessionKey =
"RadGanttSample"
;
XmlGanttProvider Provider
{
get
{
XmlGanttProvider provider = (XmlGanttProvider)Session[ProviderSessionKey];
if
(Session[ProviderSessionKey] ==
null
|| !IsPostBack)
{
provider =
new
XmlGanttProvider(Server.MapPath(
"~/App_Data/Tasks.xml"
),
true
);
Session[ProviderSessionKey] = provider;
}
return
provider;
}
}
private
void
Page_Init(
object
sender, EventArgs e)
{
RadGantt1.Provider = Provider;
}
}
In the example the Gantt is bound through an XML provider, so in order to run the example you could create an XML file with name Tasks in App_Data using the file structure from our article.
Regards,
Ivan Danchev
Telerik by Progress
Great, now it's working !
I think that this line was the key:
var $ = $telerik.$;
Thank you very much :) !
I am glad it worked out. $telerik.$ is used to access jQuery embedded in the Telerik assembly. More information about this is available here.
Regards,
Ivan Danchev
Telerik by Progress