2011-08-31 87 views
1

我遇到了一些麻烦,我认为,radSchedular。如何在更改绑定数据集后刷新radSchedule?

我有一个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();} 

我如何存储数据a第二,我想,刷新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

数据集是否暴露IObservable? –

+0

不,我不认为DataSets可以。 – Richard210363

回答

0

我能够把下面这两行代码在事件RadScheduler1_AppointmentInsertRadScheduler1_AppointmentDelete月底解决这一问题我自己。这两条线是:

Appointments.Clear(); 
InitializeAppointments(); 

这将只适用于您,如果您按照Telerik网站上给出的示例设置您的网格。你可以在这里找到链接:https://demos.telerik.com/aspnet-ajax/scheduler/examples/overview/defaultcs.aspx

相关问题