This is a migrated thread and some comments may be shown as answers.

[Solved] Inserting with custom data source

5 Answers 231 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
antonio
Top achievements
Rank 1
antonio asked on 22 May 2008, 11:33 PM
Hello,

I need some help inserting appointments while using a custom data source.
The scheduler shows OK, it reads existing data OK, the insert/edit forms show OK; the problem is that when you hit "Insert" or "Update", it does not save anything.  Is there a tag or a setting that needs to be enabled for this?

Thanks.

5 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 26 May 2008, 01:47 PM
Hello Antonio,

You do not need to set any specific property in order to enable the Insert/Update operations. Can you please verify that you have defined the insert and update commands in your data source? You can also send us the source code of the page you are working on, so we will be able to diagnose the problem faster.

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
antonio
Top achievements
Rank 1
answered on 27 May 2008, 02:23 PM
Hello,
I have defined just the "Insert" routine in my custom data source and found out something interesting.  If I open the advanced edit dialog (either on a new or existing record), and then click on "Insert" (or "Update"), the corresponding routines in my datasource are never called.  However, if I pick an existing appointment and drag-and-drop it to a new date, then the "Update" routine is executed.  Since by default it's implemented to throw an exception, that's what it does but that's fine with me.
So, is there anything special I need to do when I use the advanced dialog?

Here's the source for the definition of the RadScheduler control:

<

telerik:radscheduler id="RadScheduler1" runat="server" skin="Outlook" OverflowBehavior="Expand" OnClientAppointmentContextMenu="appointmentContextMenu" 
DataKeyField="ID" DataEndField = "End" DataRecurrenceField = "RecurrenceRule" DataRecurrenceParentKeyField = "RecurrenceParentID" DataStartField = "Start" DataSubjectField = "Subject" StartInsertingInAdvancedForm="true" StartEditingInAdvancedForm="true" ><AppointmentTemplate><div style="background-color:Aqua"><%# Eval("Subject") %><asp:Image ID="harmonyIcon" runat="server" /></div>  </AppointmentTemplate>
</
telerik:radscheduler>

0
T. Tsonev
Telerik team
answered on 29 May 2008, 01:08 PM
Hello Antonio,

I do not see the DataSourceID attribute defined in the RadScheduler tag. Do you set it from code behind? Please, send us the complete page, if adding it to the control tag does not help.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
antonio
Top achievements
Rank 1
answered on 29 May 2008, 01:40 PM
Hello Tsvetomir,

We defined the custome datasource as follows:
(This is in Page_Load)

MyDbSchedulerProvider schedulerProvider = new MyDbSchedulerProvider();

RadScheduler1.Provider = schedulerProvider;

RadScheduler1.Rebind();


Here is the code for MyDbSchedulerProvider:

public

class MyDbSchedulerProvider : DbSchedulerProviderBase

{

public override void Delete(RadScheduler owner, Appointment appointmentToDelete)

{

throw new System.Exception("The method or operation is not implemented.");

}

// loading appointments

public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)

{

List<Appointment> appointments = new List<Appointment>();

Database db = Harmony.Data.DataFactoryBase.GetHarmonyDatabase();

DBCommandWrapper dbCommandWrapper = db.GetStoredProcCommandWrapper("p_WH_AppointmentListFetch");

dbCommandWrapper.AddInParameter(

"CaseNo", DbType.Int64, ContextInfo.Current.ChapterEntityID);

dbCommandWrapper.AddInParameter(

"UserID", DbType.Int32, UserSessionData.Current.UserID);

dbCommandWrapper.AddInParameter(

"RoleID", DbType.Int32, UserSessionData.Current.RoleID);

dbCommandWrapper.AddInParameter(

"DynamicSQL", DbType.AnsiString, "");

dbCommandWrapper.AddInParameter(

"PageNumber", DbType.Int32, 1);

dbCommandWrapper.AddInParameter(

"PageSize", DbType.Int32, 1000);

dbCommandWrapper.AddInParameter(

"SortExpression", DbType.AnsiString, "");

dbCommandWrapper.AddInParameter(

"SortOrder", DbType.AnsiString, "");

DataSet dsAppointments = db.ExecuteDataSet(dbCommandWrapper);

if (dsAppointments != null)

{

foreach (DataRow dr in dsAppointments.Tables[0].Rows)

{

Appointment apt = new Appointment();

apt.Owner = owner;

apt.ID = dr[

"EntityID"];

apt.Subject =

Convert.ToString(dr["Description"]);

apt.Start =

Convert.ToDateTime(dr["StartDate"]);

apt.End =

Convert.ToDateTime(dr["EndDate"]);

// since this is a proof of concept we'll use existing fields rather than modifying the structure

apt.RecurrenceRule =

Convert.ToString(dr["ApptGenericText2"]);

apt.RecurrenceParentID = dr[

"TeamId"] == DBNull.Value ? null : dr["TeamId"];

if (apt.RecurrenceParentID != null)

{

apt.RecurrenceState =

RecurrenceState.Exception;

}

else if (apt.RecurrenceRule != string.Empty)

{

apt.RecurrenceState =

RecurrenceState.Master;

}

LoadResources(apt);

appointments.Add(apt);

}

}

return appointments;

}

-------------------------------------

We are not using Telerik's RadAjaxManager or RadAjaxPanel because we already implement MS AJAX, and it certainly cannot intercept any events from your advanced-template.
As I mentioned before, the drag-and-drop does fire the 'update' event but the 'insert' button in your advanced-template does not do anything.

Thanks.
0
T. Tsonev
Telerik team
answered on 02 Jun 2008, 11:27 AM
Hi,

Everything looks alright with your provider. The problem seems to be the call to Rebind() in Page_Load. Removing it should resolve the issue.

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
antonio
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
antonio
Top achievements
Rank 1
Share this question
or