1

我认为,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()}
4

1 回答 1

0

通过将这两行代码放在事件的末尾RadScheduler1_AppointmentInsertRadScheduler1_AppointmentDelete. 这两行是:

Appointments.Clear();
InitializeAppointments();

仅当您按照 Telerik 网站上给出的示例设置网格时,这才对您有用。您可以在此处找到链接:https ://demos.telerik.com/aspnet-ajax/scheduler/examples/overview/defaultcs.aspx

于 2017-10-06T17:53:34.157 回答