Hi
I allow myself to relaunch you on topics that have not had answers to know :
If is there a way to show week numbers rather dates ? is it possible to modify radGantt WeekHeaderDateFormat like this : Week 15, Week 16...
If there is a way to customize the pop-up window, prevent click action on a task or call a custom window ?
tested with the product version : 2018.2.516.45
Best regards
7 Answers, 1 is accepted
Showing "Week 1" functionality can be achieved with the following JavaScript based on the Gantt Localization demo.
What you should add to the Gantt markup declaration is the WeekView-WeekHeaderDateFormat="dd/MM/yyyy" and OnClientDataBound="OnClientDataBound" properties.
<
telerik:RadGantt
RenderMode
=
"Lightweight"
runat
=
"server"
ID
=
"RadGantt1"
SelectedView
=
"WeekView"
AutoGenerateColumns
=
"false"
Height
=
"640px"
DataSourceID
=
"TasksDataSource"
WeekView-WeekHeaderDateFormat
=
"dd/MM/yyyy"
OnClientDataBound
=
"OnClientDataBound"
DependenciesDataSourceID
=
"DependenciesDataSource"
>
function
getWeekNumber(d) {
// Copy date so don't modify original
d =
new
Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
// Set to nearest Thursday: current date + 4 - current day number
// Make Sunday's day number 7
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
// Get first day of year
var
yearStart =
new
Date(Date.UTC(d.getUTCFullYear(), 0, 1));
// Calculate full weeks to nearest Thursday
var
weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
// Return array of year and week number
// return [d.getUTCFullYear(), weekNo];
return
weekNo
}
function
OnClientDataBound(sender, args) {
if
(sender.get_viewsData()[sender.get_selectedView()].type ==
"week"
) {
$telerik.$(
'.rgtTimelineWrapper thead>tr:first .radHeader'
, sender.get_element()).each(
function
(index) {
var
$
this
= $(
this
)
var
datestring = $
this
.text().substring(0, 10);
var
date =
new
Date(datestring);
var
weekNumber = getWeekNumber(date)
$
this
.text(
"Week "
+ weekNumber)
})
}
}
We have created a Feature request in our Feedback portal where you can cast your vote and subscribe - Allow templates for HeaderDateFormat in RadGantt.
Regarding the Custom edit window, please check the Custom Task Edit Window article - https://docs.telerik.com/devtools/aspnet-ajax/controls/gantt/how-to/custom-task-edit-window
Regards,
Peter Milchev
Progress Telerik
Thank you,
Great ! I managed to display the list of weeks.
On the other hand, I can not modify the Localization even after having the example.
I wonder if it does not miss a file in the directory bin or other ...
I continue with the custom edit window article.
Regards,
Salvatore
The Localization is not working in the sample project as the resource files are missing from the App_GlobalResources folder.
Attached is an archive with the Resources files for many controls which can be found in the demos you might have installed locally.
Regards,
Peter Milchev
Progress Telerik
Hi Peter,
Thank's
I have a problem when I add a control button,
<asp:Button ID="Button1" runat="server" Text="Button" />
after putting a breakpoint when I click on it, I do not go into the event ...
Regards,
Salvatore
Are there any JavaScript errors in the browser console and did you subscribe correctly to the event of the button?
As this is not related to the original topic of this thread, would you please open a new thread with the button issue? You can prepare a simple sample runnable project replicating the issue and attach it to an official support ticket for us to investigate it locally.
Regards,
Peter Milchev
Progress Telerik
Peter,
I'm sorry, I did a wrong thing. Would it be possible to delete the two tickets I just created so that I can create a new one with the test project.
I did not have any JavaScript errors...
Regards,
Salvatore
I have answered in the other thread where we can continue the discussion.
For convenience, I am sharing the link to the thread related to your button query - https://www.telerik.com/forums/event-click-doesn't-work-with-gantt.
Regards,
Peter Milchev
Progress Telerik