我认为我在使用radSchedular时遇到了一些麻烦。
我有一个radSchedular,它绑定到数据集。
我希望在更改数据集时更新radSchedular。但我不明白这一点。
我的问题是。如何在数据集更新时更新radSchedular的显示?
示例代码:
我如何绑定: -
private void BindToDataSet()
{
//Map fields for Appointments
AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
appointmentMappingInfo.Start = "appointments_Start";
appointmentMappingInfo.End = "appointments_End"; //LOTS OF THESE SO I CUT THE REST OUT OF THIS EXAMPLE
datasource.EventProvider.Mapping = appointmentMappingInfo;
datasource.EventProvider.DataSource = dsSchedule.Tables[0]; //MY DATASET IS GENERATED FROM AN XML FILE WITH A SCHEMA
//Bind
radScheduler1.DataSource = datasource;
}
我如何获得数据集更改事件: -
private void BindEvents(){
// RowChanged event handler.
dsSchedule.Tables[0].RowChanged += new DataRowChangeEventHandler(RowChanged);
// Add a RowDeleted event handler.
dsSchedule.Tables[0].RowDeleted += new DataRowChangeEventHandler(RowDeleted);}
事件方法: -
private void RowChanged(object sender, DataRowChangeEventArgs e){
StoreToXML();
BindEvents();}
我如何存储数据,我想,刷新radSchedular: -
private void StoreToXML(){
//remove the dataset change deligates as we are about to change the Dataset and we don't want a loop
UnBindEvents();
foreach (DataRow rowAppointments in dsSchedule.Tables["Appointments"].Rows)
{
string currentResource = rowAppointments["appointments_ResourceID"].ToString();
foreach (DataRow rowResources in dsSchedule.Tables["Resources"].Rows)
{
if (rowResources["resources_ID"].ToString() == currentResource)
{
rowAppointments["appointments_Location"] = rowResources["resources_Name"]; //THIS IS WHY I WANT THE radSCHEDULAR TO UPDATE.
} //I WANT TO SEE THE RESOURCE IN THE LOCATION FIELD
}
}
StreamWriter myStreamWriter = new StreamWriter(@"E:\My .NET\Hardware_Scheduler_Application\stdData.xml");
dsSchedule.WriteXml(myStreamWriter, XmlWriteMode.WriteSchema);
myStreamWriter.Close();
BindToDataSet(); //I THOUGHT THAT THIS WOULD REFRESH THE radSCHEDULAR
//rebind the changed events
BindEvents()}
答案 0 :(得分:0)
我可以通过在事件alt
和RadScheduler1_AppointmentInsert
结尾处放置以下两行代码来自行解决此问题。这两行是:
RadScheduler1_AppointmentDelete
如果您按照Telerik网站上给出的示例设置网格,则此功能仅适用于您。您可以在此处找到链接:https://demos.telerik.com/aspnet-ajax/scheduler/examples/overview/defaultcs.aspx