We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Update SfSheduler after save new appointment.

Thread ID:

Created:

Updated:

Platform:

Replies:

149793 Dec 9,2019 07:01 PM UTC Jan 22,2020 01:13 PM UTC Xamarin.Forms 10
loading
Tags: SfSchedule
Henrique
Asked On December 9, 2019 07:01 PM UTC

Hi,

I need refresh de scheduler component after save new appointment. 

I try changed datasource object, but not occurs nothing.

Is possible this? How?

Thanks a lot.

Indumathi Ravichandran [Syncfusion]
Replied On December 10, 2019 12:41 PM UTC

Hi Henrique, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we suspect that you have mentioned the issue “DataSource is not updated when adding new appointment” and we are unable to replicate from our end. We have tested by adding new appointment and the DataSource updated properly. It is working fine as expected. Please find the sample and screenshot from the following link. 
 
 
 
We have tested with Syncfusion update version 17.3.0.34 and Xamarin.Forms version 3.6.0.344457 in the Honor 9N device
 
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with below details, 
 
·       Device configuration details 
·       Issue reproducing video (if possible) 
·       Syncfusion and Xamarin.Forms update version 
·       Appointment type (Schedule/Custom Appointment) 
 
For more details adding Appointments, please refer the below UG link, 
 
UG links:  
 
 
It will be helpful for us to check on it and provide you solution at the earliest. 
 
Regards, 
Indumathi R 


Henrique
Replied On January 15, 2020 02:13 PM UTC

Hi,

The code that sended me is not ok. I'm using the code below:

<syncfusion:SfSchedule x:Name="schedule" FirstDayOfWeek="1" ScheduleView="MonthView" ShowAppointmentsInline="True" DataSource = "{Binding Meetings}"
                               AllowAppointmentDrag="true" Locale="pt" Margin="10,0,10,0">
             <syncfusion:SfSchedule.MonthViewSettings>
                <syncfusion:MonthViewSettings
                        AppointmentIndicatorCount = "8" MonthNavigationDirection="Horizontal" SelectionTextColor="Red" >
                </syncfusion:MonthViewSettings>
             </syncfusion:SfSchedule.MonthViewSettings>
            <syncfusion:SfSchedule.AppointmentMapping>
   <syncfusion:ScheduleAppointmentMapping
   ColorMapping="color"
   EndTimeMapping="To"
   StartTimeMapping="From"
   SubjectMapping="EventName" 
   IsAllDayMapping="AllDay"/>
       </syncfusion:SfSchedule.AppointmentMapping>
        </syncfusion:SfSchedule>

When I fire my page, I'm using MVVM connected to firebase:

 BindingContext = new CalendarioViewModel(App.UID):

public class CalendarioViewModel
    {
        public ObservableCollection<Agendamento> Meetings { get; set; }

        List<string> eventNameCollection;
        List<Color> colorCollection;

        public string _query { get; set; }

        public CalendarioViewModel(string uid)
        {
            Meetings = new ObservableCollection<Agendamento>();

            _query = uid;

            CreateColorCollection();
            LoadData();
        }

        private async void LoadData()
        {
            AgendamentoDB _db = new AgendamentoDB() { UID = _query };

            List<Agendamento> _agendamento = await _db.GetAgendamentos(); -- Data from Firebase

            Random randomTime = new Random();

            int i = 0;

            try
{
foreach (var item in _agendamento)
{
string[] _data = item.Data.Split('/');
                    string[] _horainic = item.HoraInic.Split(':');
                    string[] _horafim = item.HoraFim.Split(':');

DateTime _datetimeinic = new DateTime(Convert.ToInt32(_data[2]), Convert.ToInt32(_data[1]), Convert.ToInt32(_data[0]), Convert.ToInt32(_horainic[0]), Convert.ToInt32(_horainic[1]), 0);
                    DateTime _datetimefim = new DateTime(Convert.ToInt32(_data[2]), Convert.ToInt32(_data[1]), Convert.ToInt32(_data[0]), Convert.ToInt32(_horafim[0]), Convert.ToInt32(_horafim[1]), 0);

                    //Componente mostra uma hora a menos - sem motivo aparente.
                    _datetimeinic = _datetimeinic.AddHours(1);
                    _datetimefim = _datetimefim.AddHours(1);                   

                    Agendamento meeting = new Agendamento();
                    meeting.From = new DateTime(_datetimeinic.Year, _datetimeinic.Month, _datetimeinic.Day, _datetimeinic.Hour, _datetimeinic.Minute, 0);
                    meeting.To = new DateTime(_datetimefim.Year, _datetimefim.Month, _datetimefim.Day, _datetimefim.Hour, _datetimefim.Minute, 0);

                    if (!string.IsNullOrEmpty(item.Tipo))
                    {
                        meeting.EventName = item.Paciente + " - " + item.Procedimento + " - " + item.Tipo;
                    }
                    else
                    {
                        meeting.EventName = item.Paciente + " - " + item.Procedimento;
                    }
                    
                    meeting.color = colorCollection[randomTime.Next(i)];
                    meeting.ContactID = item.Key;
                    meeting.Procedimento = item.Procedimento;
                    meeting.Tipo = item.Tipo;
                    meeting.Paciente = item.Paciente;
                    meeting.UIDPaciente = item.UIDPaciente;

                    Meetings.Add(meeting);

                    i++;

                }
            }
            catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
        }

So, I have one popup-up to update any appointments.When I update only, the component no update. I tried update the DataSource, but the action not have well. The data is not updated.

List<Agendamento> _tmp = new List<Agendamento>();

            _tmp.Add(new Agendamento()
            {
                From = new DateTime(2019, 01, 16, 14, 0, 0),
                To = new DateTime(2019, 01, 16, 15, 0, 0),
                EventName = "Meeting",
                color = Color.Violet
            });

            schedule.DataSource = _tmp;

You can help me, please?

Tks a lot.


Ganeshamoorthy Chandramoorthy [Syncfusion]
Replied On January 17, 2020 02:13 PM UTC

Hi Henrique, 
 
Thanks for the update. 
 
We have checked your query based on the provided information. We have prepared simple sample in MVVM pattern to update the schedule DataSource at run time, in this sample instead of firebase we have used local JSON data to bind schedule appointments. Kindly find the code snippet and sample below, 

Code snippet:
 
    <ContentPage.Behaviors> 
        <local:ScheduleBehavior/> 
    </ContentPage.Behaviors> 
 
    <ContentPage.Content> 
 
        <Grid> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="0.05*"/> 
                <RowDefinition Height="0.95*"/> 
            </Grid.RowDefinitions> 
 
            <Button x:Name="button" Text="Add new Appointment"/> 
            <schedule:SfSchedule x:Name="schedule" Grid.Row="1" 
        DataSource = "{Binding Meetings}" 
        ScheduleView = "WeekView" > 
            <schedule:SfSchedule.AppointmentMapping> 
                <schedule:ScheduleAppointmentMapping 
                ColorMapping="Color" 
                EndTimeMapping="To" 
                StartTimeMapping="From" 
                SubjectMapping="EventName" 
                IsAllDayMapping="AllDay"/> 
            </schedule:SfSchedule.AppointmentMapping> 
            <schedule:SfSchedule.BindingContext> 
                <local:ViewModel/> 
            </schedule:SfSchedule.BindingContext> 
        </schedule:SfSchedule> 
 
        </Grid> 
    </ContentPage.Content> 
  
 
    class ScheduleBehavior : Behavior<ContentPage> 
    { 
        SfSchedule schedule; 
        Button button; 
        protected override void OnAttachedTo(ContentPage bindable) 
        { 
            base.OnAttachedTo(bindable); 
            schedule = bindable.FindByName<SfSchedule>("schedule"); 
            button = bindable.FindByName<Button>("button"); 
            button.Clicked += AddAppointment; 
            schedule.MoveToDate = new DateTime(2018, 08, 30, 9, 0 ,0); 
        } 
 
        private void AddAppointment(object sender, EventArgs e) 
        { 
            var viewModel = schedule.BindingContext as ViewModel; 
            viewModel.Meetings.Add(new Meeting() 
            { 
                From = new DateTime(2018, 08, 30, 11, 0, 0), 
                To = new DateTime(2018, 08, 30, 13, 0, 0), 
                EventName = "New Appointment", 
                Color = Color.SaddleBrown 
            }); 
        } 
    } 
 
 
For more details, you refer our Knowledge base to bind schedule appointment using from JSON data and Outlook calendar using below link,
 
 
 
We hope this helps. Kindly revert us if you have any concerns.

Regards, 
Ganeshamoorthy C 


Henrique
Replied On January 19, 2020 04:37 PM UTC

Hi,

Sorry but this last solution sended me is not working. I my case we using the pop-up page to update data. I tried put the last code, but is not work.

Exist other possibilities to update BindContext from other page?

Tks a lot.

Henrique
Replied On January 19, 2020 04:40 PM UTC

More details about my last post.

The pop-up page update firebase and after I need refresh de scheduler. Tks a lot.

Karthikraja Arumugam [Syncfusion]
Replied On January 20, 2020 09:23 AM UTC

Hi Henrique, 
 
Thank you for the update. 
 
Based on the shared information we have checked your requirement of “Update schedule DataSource at runtime”. We have prepared a sample based on your requirement, since you are using DataBase, after updating firebase get that appointment from firebase and add it to the schedule DataSource. In the sample, we have used SQLite offline database. 
 
Please refer the following code example for the same, 
 
private void AddAppointment(object sender, EventArgs e) 
       
            var viewModel = schedule.BindingContext as AppointmentViewModel; 
          
           // Get appointment from database 
            var table = (from i in database.Table<AppointmentDB>() select i); 
            foreach (var order in table) 
           
                viewModel.Meetings.Add(new Meeting() 
               
                    EventName = order.Subject, 
                    From = DateTime.Parse(order.StartTime), 
                    To = DateTime.Parse(order.EndTime), 
                    Color = Color.FromHex(order.Color), 
                    AllDay = Convert.ToBoolean(order.AllDay), 
                }); 
           
       
 
We have prepared a sample based on your requirement, 
Sample link: SqliteSample 
 
You can also refer our KB documentation for more information on loading DataSource from SQLite database, 
 
We hope this helps. Please let us know if you need any further assistance. 
 
Regards, 
Karthik Raja A

Henrique
Replied On January 20, 2020 12:07 PM UTC

Hi,

The line below not return my appointments collection. 

 schedule = bindable.FindByName<SfSchedule>("schedule"); 

I attachment one file to view this.

Tks a lot.

Attachment: Captura_de_Tela_20200120_às_09.05.46_41cf671d.zip

Karthikraja Arumugam [Syncfusion]
Replied On January 21, 2020 09:39 AM UTC

Hi Henrique, 
 
Thank you for the update. 
 
We have checked the mentioned issue and since you cannot get Appointment collection from BindingContext you can directly add new appointment to Schedule DataSource, kindly check the behavior page returns the actual Schedule object and add new appointment to the schedule DataSource.  
 
Please refer the following code example for the same, 
 
private void AddAppointment(object sender, EventArgs e) 
{ 
            var dataSource = schedule.DataSource as ObservableCollection<Meeting>; 
 
            var table = (from i in database.Table<AppointmentDB>() select i); 
            foreach (var order in table) 
            { 
                dataSource.Add(new Meeting() 
                { 
                    EventName = order.Subject, 
                    From = DateTime.Parse(order.StartTime), 
                    To = DateTime.Parse(order.EndTime), 
                    Color = Color.FromHex(order.Color), 
                    AllDay = Convert.ToBoolean(order.AllDay), 
                }); 
            } 
 } 
 
We have prepared a sample based on your requirement, 
Sample link: SqliteSample 
 
We hope this helps. Kindly revert us if you need any further assistance. 
 
Regards, 
Karthik Raja A 


Henrique
Replied On January 21, 2020 12:06 PM UTC

Hi,

Same problem...

Remember: I updated scheduler component from other page. After update data, the app return to page where have scheduler and will demonstrate the update data.

Tks


Attachment: Captura_de_Tela_20200121_às_09.03.41_2f415518.zip

Karthikraja Arumugam [Syncfusion]
Replied On January 22, 2020 01:13 PM UTC

Hi Henrique, 
 
Thank you for the update. 
 
As mentioned in our previous update, please check your current page returns actual Schedule object if that object is returned from Schedule page it will have the binding context and data source values. We suspect that the object is not getting from actual Scheduler page. 
 
If the shared information doesn’t help you to achieve your requirement kindly modify the sample attached with our previous update, based on your scenario and revert us back. It will be helpful for us to analyze further and provide you the possible solution at the earliest or we can set up a web meeting to resolve the issue at your end. Would you please get back to us on your availability for web meeting? 
 
Regards, 
Karthik Raja A 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon