I downloaded one of your demos for the radscheduler. I connected it to my database and it almost does the job I need it to do. Basically I'm trying to do schedule for my employees. So I don't necessarily need the subject box instead I would like to see the names of the employees working the shift. This is the demos that i'm using http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultcs.aspx
I can have more than 1 employee working the same shift. Also I was wondering if it's possible to dynamically create the toggle button with the name of my employees coming from my database. Thank you in advance for all the help you can provide me.
13 Answers, 1 is accepted
In such scenarios we recommend using Appointment templates and Multiple resources as for example it is implemented in this on-line demo.
Regards,
Plamen
Telerik

Thanks
This could be achieved if you group vertically as for example it can be done in this on-line demo.
Regards,
Plamen
Telerik

I tried another approach with a regular GridView. It does what I need but now I would like to recreate it using RadGrid. Can you please tell me how to make this code work in RadGrid please:
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (var i = 1; i <= 7; i++)
{
var hDate = new HiddenField { ID = "hDate" + i, Value = string.Format("{0:yyyy-MM-dd}", _weekStart.AddDays(i - 1)) };
e.Row.Cells[i].Controls.Add(hDate);
var hEmployeeId = new HiddenField { ID = "hEmployeeId" + i, Value = ((DataRowView)e.Row.DataItem).Row["EmployeeId"].ToString() };
e.Row.Cells[i].Controls.Add(hEmployeeId);
var lstStart = TimeListBox("lstStart" + i, ((DataRowView)e.Row.DataItem).Row[GetDay(i) + "S"].ToString());
e.Row.Cells[i].Controls.Add(lstStart);
var lstEnd = TimeListBox("lstEnd" + i, ((DataRowView)e.Row.DataItem).Row[GetDay(i) + "E"].ToString());
e.Row.Cells[i].Controls.Add(lstEnd);
var lstStoreSection = StoreSectionListBox("lstStoreSection" + i, ((DataRowView)e.Row.DataItem).Row[GetDay(i) + "SS"].ToString());
e.Row.Cells[i].Controls.Add(lstStoreSection);
}
var lnkView = new LinkButton { ID = "lnkView", Text = "View" };
lnkView.Click += ViewDetails;
lnkView.CommandArgument = ((DataRowView)e.Row.DataItem).Row["Id"].ToString();
e.Row.Cells[8].Controls.Add(lnkView);
}
}

What I see from the code is that controls are being added in the rows cells dynamically. For achieving the same using RadGrid I would suggest subscribing to the OnItemCreated event. The code would look something similar to this.
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(item !=
null
)
{
for
(var i = 1; i <= 7; i++)
{
var hDate =
//Create control
item.Cells[i].Controls.Add(hDate);
var hEmployeeId =
//Create control
item.Cells[i].Controls.Add(hEmployeeId);
var lstStart =
//Create control
item.Cells[i].Controls.Add(lstStart);
var lstEnd =
//Create control
item.Cells[i].Controls.Add(lstEnd);
var lstStoreSection =
//Create control
item.Cells[i].Controls.Add(lstStoreSection);
}
}
}
Note that if you want to populate the dynamically added controls you should do so by subscribing to the OnItemDataBound event.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(item !=
null
)
{
//populate the controls
}
}
Regards,
Angel Petrov
Telerik

Now let say that I would like to get the value of the selected value from a dropdownlist on the clien side. My goal is to create a column Total at the end of my grid and calculate the total amount of each selected dropdownlist.
I found this example somewhere on the forum but it needs to be modified to fit my needs but I have no clue how to do it:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function OnGridCreated(sender, eventArgs) {
var radgrid = $telerik.$(".radGrid");
alert("The ID of the RadGrid: " + radgrid[0].id);
$telerik.$('.textbox').blur(function () {
alert('Handler for .blur() called.');
});
$telerik.$('.ddl').blur(function () {
alert('DDL Changed');
});
}
</script>
</telerik:RadScriptBlock>
Since the last code demonstrated how to add a control in the GridDataItem I suppose that the DropDownList is placed inside the ItemTemplate of a GridTemplateColumn. If that is the case you can extract the value in the blur event handler. An exemplary scenario is shown in the code snippets below:
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"MyColumn"
>
<
ItemTemplate
>
<
asp:DropDownList
runat
=
"server"
CssClass
=
"ddl"
ID
=
"DropDownList1"
>
<
asp:ListItem
Value
=
"1"
Text
=
"1"
></
asp:ListItem
>
<
asp:ListItem
Value
=
"2"
Text
=
"2"
></
asp:ListItem
>
<
asp:ListItem
Value
=
"3"
Text
=
"3"
></
asp:ListItem
>
<
asp:ListItem
Value
=
"4"
Text
=
"4"
></
asp:ListItem
>
<
asp:ListItem
Value
=
"5"
Text
=
"5"
></
asp:ListItem
>
</
asp:DropDownList
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnGridCreated
=
"OnGridCreated"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
JavaScript:
function
OnGridCreated(sender, eventArgs) {
$telerik.$(
'.ddl'
).blur(
function
(e) {
var
value = e.currentTarget.value;
});
}
If this is not the case please elaborate more on the exact scenario. Note that it would be best to show us the markup of the grid so we could get a better understanding of the setup.
Regards,
Angel Petrov
Telerik

In order to have a better control over the client selection process I would recommend replacing the DropDownList with a RadComboBox. This will allow you to subscribe to the OnClientSelectedIndexChanged event which is fired after an item is selected. Inside the event handler logic you can traverse the grid items and obtain the values of all the combos. If we refer to the previous sample you can modify it like this.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"MyColumn"
>
<
ItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
CssClass
=
"ddl"
ID
=
"RadComboBox1"
OnClientSelectedIndexChanged
=
"selectedIndexChanged"
>
<
Items
>
<
telerik:RadComboBoxItem
Value
=
"1"
Text
=
"1"
/>
<
telerik:RadComboBoxItem
Value
=
"2"
Text
=
"2"
/>
<
telerik:RadComboBoxItem
Value
=
"3"
Text
=
"3"
/>
<
telerik:RadComboBoxItem
Value
=
"4"
Text
=
"4"
/>
<
telerik:RadComboBoxItem
Value
=
"5"
Text
=
"5"
/>
</
Items
>
</
telerik:RadComboBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
JavaScript:
function
selectedIndexChanged(sender, args) {
var
targetedComboValue = args.get_item().get_value();
//Extracting all the combos values
var
gridItems = $find(
'<%=RadGrid1.ClientID%>'
).get_masterTableView().get_dataItems();
for
(
var
i = 0; i < gridItems.length; i++) {
var
combo = $telerik.findControl(gridItems[i].get_element(),
"RadComboBox1"
);
var
value = combo.get_selectedItem().get_value();
}
}
Regards,
Angel Petrov
Telerik

Thanks for your reply. But it doesn't work. I tried the following:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function selectedIndexChanged(sender, args) {
var gridItems = $find('<%=gvSchedule.ClientID%>').get_masterTableView().get_dataItems();
alert(gridItems.length);
}
</script>
</telerik:RadScriptBlock>
Am I missing something?
I am experiencing difficulties understanding the problem. Are you saying that the count of the grid items is zero? Could you ensure that there was no JavaScript error present on the page prior to the execution of the illustrated code?
Please elaborate more on the exact scenario thus facilitating us in providing an accurate answer. Additionally It would be best to show us the entire page contents so we could review the implementation.
Regards,
Angel Petrov
Telerik

[quote]Emmanuel said:Hi,
I downloaded one of your demos for the radscheduler. I connected it to my database and it almost does the job I need it to do. Basically I'm trying to do schedule for my employees. So I don't necessarily need the subject box instead I would like to see the names of the employees working the shift. This is the demos that i'm using http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultcs.aspx
I can have more than 1 employee working the same shift. Also I was wondering if it's possible to dynamically create the toggle button with the name of my employees coming from my database. Same is used on mywegmansconnect portal. Thank you in advance for all the help you can provide me.[/quote]
Along this topic, can the RadScheduler be utilized where we have a
population of employees that are to be assigned to one or more scheduled
routes. An employee can only be assigned to one route per day.
A route may consist of one or more jobs.
In this scenario, I have a set population of employees to assign to
route and a population of jobs (or those to be added). We also have
resources like vehicle to be used, apparel to be worn, etc...
Can I take the scheduler this far?