Use Integer as UniqueID

6 posts, 1 answers
  1. Daniel
    Daniel avatar
    9 posts
    Member since:
    Feb 2017

    Posted 24 Apr 2017 Link to this post

    The demo examples that are provided all use Integer in their tables, but the code uses a Guid.

    I know that I must use the "ConvertUniqueIdToDataSource" method, but I'm missing the actual conversion part.  After researching online, everyone says converting from a Guid to an Integer is not possible.  So I'm not sure where to go from here.  All of my SQL tables use an auto-incrementing integer.

    I'm missing this code:

     object ConvertUniqueIdToDataSource(object obj)
            {
                EventId eventId = obj as EventId;
                //if the appointment is added from the scheduler the eventId.KeyValue is Guid
                if (eventId.KeyValue is Guid)
                {
                    //return the value that is in your object/dataset
                    // --- WHAT DO I PUT RIGHT HERE?  HOW DO I RETURN AN INTEGER?

                }
                //if the appointment is loaded from an object/dataset the eventId.KeyValue is its representation in the object/datase
                return eventId.KeyValue;
            }

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3321 posts

    Posted 25 Apr 2017 Link to this post

    Hello Daniel, 

    Thank you for writing.  

    Converting integer to GUID is a general programming question. You can refer to the following StackOverflow threads that are quite useful on this topic:
    http://stackoverflow.com/questions/4825907/convert-int-to-guid
    http://stackoverflow.com/questions/3303829/create-a-guid-from-an-int

    When you bind RadScheduler with data, the appointments' id in your database is automatically updated when a new record is added. Hence, it is not expected to be managed by the user or bind it to the Appointment.UniqueId property. Please refer to the following help article demonstrating how to bind RadScheduler with data and store the changes to your database: http://docs.telerik.com/devtools/winforms/scheduler/data-binding/data-binding-walkthrough

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Daniel
    Daniel avatar
    9 posts
    Member since:
    Feb 2017

    Posted 25 Apr 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    If I don't convert and have the Scheduler use it's default which is a Guid I believe and my my table is using an integer as it's Primary Key, the scheduler doesn't show any appointments.  

    Here's my mapping:

       schedulerBindingDataSource1 = new SchedulerBindingDataSource();
                    AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
                    appointmentMappingInfo.UniqueId = "app_pk";
                    appointmentMappingInfo.Start = "app_start";
                    appointmentMappingInfo.End = "app_end";
                    appointmentMappingInfo.Summary = "app_summary";
                    appointmentMappingInfo.Description = "app_description";
                    appointmentMappingInfo.Location = "app_location";
                    appointmentMappingInfo.BackgroundId = "app_backgroundid";
                    appointmentMappingInfo.StatusId = "app_status";
                    appointmentMappingInfo.RecurrenceRule = "app_recurrencerule";
                    appointmentMappingInfo.ResourceId = "app_res_id";
                    appointmentMappingInfo.Exceptions = "AppointmentsAppointments";
                    appointmentMappingInfo.MasterEventId = "app_mastereventid";
                    appointmentMappingInfo.Visible = "app_visible";
                    appointmentMappingInfo.AllDay = "app_allday";
                    appointmentMappingInfo.AllowDelete = "app_allowdelete";
                    appointmentMappingInfo.AllowEdit = "app_allowedit";

    I've attached what my dataset looks like, which is what is bound to the Scheduler Binding datasource.

    My app_pk is an auto-incrementing PK.  Does Telerik prefer UniqueID to be a Guid? I can do that but will need to tweak some stored procedures to make it work.

     

  4. Daniel
    Daniel avatar
    9 posts
    Member since:
    Feb 2017

    Posted 25 Apr 2017 in reply to Daniel Link to this post

    If I don't attempt conversion, I get the attached error.  I've seen others in this forum get it as well but there aren't any answers to what they did to fix it.

    If I don't need to manage it, then should I un-assign it in the mapping?

  5. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3321 posts

    Posted 26 Apr 2017 Link to this post

    Hello Daniel, 

    Thank you for writing back. 

    I have prepared a sample project for your reference demonstrating how to bind RadScheduler without mapping the UniqueID. It follows the demonstrated approach in this help article: http://docs.telerik.com/devtools/winforms/scheduler/data-binding/data-binding-walkthrough

    A backup file of my sample database is also present in the zip.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Daniel
    Daniel avatar
    9 posts
    Member since:
    Feb 2017

    Posted 26 Apr 2017 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you Dess,

    I can't use the DataSets like that due to how our Data Layer operates, but it does shed some extra light on it.  I've switched to the Guid for the Scheduler and also propagate it to my SQL table.  In SQL it ignores the Guid unless dealing with exceptions/recurrences, so I think I'm in good shape.

    Thanks for the project, I'm digging into that now.

     

Back to Top