Skip to content

Commit 91e0209

Browse files
github-actions[bot]KB Bot
and
KB Bot
authored
Added new kb article gantt-hide-percentage-values-radgantt-resource-list (#650)
Co-authored-by: KB Bot <kb-bot@telerik.com>
1 parent 7c87fb3 commit 91e0209

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Hiding Percentage Values in Resource List of RadGantt for ASP.NET AJAX
3+
description: Learn how to remove the percentage values from the resource list in RadGantt for ASP.NET AJAX using a client-side script.
4+
type: how-to
5+
page_title: How to Remove Percentage Values from Resource List in RadGantt
6+
slug: gantt-hide-percentage-values-radgantt-resource-list
7+
tags: radgantt, asp.net ajax, resource list, javascript
8+
res_type: kb
9+
ticketid: 1676341
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>RadGantt for ASP.NET AJAX</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2024.4.1114</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
In scenarios where you want to display only the names of resources in the RadGantt control without the accompanying percentage values, you might find the default format (e.g., Charlie [100%]) not suitable for your needs. This article provides a solution to remove the percentage values from the resource list, showing only the resource names.
30+
31+
This knowledge base article also answers the following questions:
32+
- How can I customize the resource list display in RadGantt for ASP.NET AJAX?
33+
- Is it possible to exclude percentage values from RadGantt's resource list?
34+
- What client-side approach can be used to modify the RadGantt resource list format?
35+
36+
## Solution
37+
38+
To achieve the removal of percentage values from the resource list in RadGantt for ASP.NET AJAX, use the following client-side JavaScript code. This script should be added to your page where the RadGantt control is used. It utilizes the `OnClientLoad` event of the RadGantt control to modify the display of resource names after the control is fully rendered.
39+
40+
````aspx
41+
<script>
42+
function OnClientLoad(sender, args) {
43+
document.querySelectorAll('table.k-selectable td[role="gridcell"]:nth-child(2)').forEach(cell => {
44+
cell.textContent = cell.textContent.replace(/\s?\[\d+\s?%\]/g, ''); // Remove percentage part
45+
});
46+
}
47+
</script>
48+
<telerik:RadGantt RenderMode="Lightweight" runat="server" ID="RadGantt1" OnClientLoad="OnClientLoad" ...
49+
````
50+
51+
- Ensure the RadGantt control includes the `OnClientLoad="OnClientLoad"` attribute to trigger the JavaScript function after the control is loaded.
52+
- This JavaScript function searches for all cells (`<td>`) in the second column of the resource list, which contain the resource names and percentage values. It then uses a regular expression to remove the percentage part.
53+
- After applying this script, only the resource names will be displayed in the resource list of the RadGantt control, omitting the percentage values.
54+
55+
## See Also
56+
57+
- [RadGantt Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/gantt/overview)
58+
- [RadGantt Client-Side Programming](https://docs.telerik.com/devtools/aspnet-ajax/controls/gantt/client-side-programming/events/onclientload)
59+
- [JavaScript Regular Expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)

0 commit comments

Comments
 (0)