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

Loading events from WebMethod

2 Answers 29 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stuart
Top achievements
Rank 1
Stuart asked on 30 Nov 2016, 01:22 PM

 I have just downloaded the iOS suite and I'd like to populate the calendar from a WebMethod (JSON)

What I'd like to do is to have the WebMethod called for the current month in the createEvents function, but when the user scrolls to a different month, the Method is called again with that months range. Is there a way to get the currently displayed months first and last days in the createEvents function?

Thanks

2 Answers, 1 is accepted

Sort by
0
Stuart
Top achievements
Rank 1
answered on 02 Dec 2016, 12:53 PM

I've managed to get this in now. Although the dots for each day with something on do not appear now. 

my current code is:

    func createEvents() {

        if self.events.count > 0 {
            self.events.removeAllObjects()
        }

        let currentDate: Date = self.calendarView.displayedDate
        let startDate: Date = Date().startOfMonth(myDate: currentDate)!
        let endDate: Date = Date().endOfMonth(myDate: currentDate)!

        let paramString : String = String(format: "Token=%@&StartDate=%@&EndDate=%@", keychain.get("sessionToken")!, DateFormatting().getStandardDate(startDate, dateTimeReq: "DateDashed"), DateFormatting().getStandardDate(endDate, dateTimeReq: "DateDashed"))

        DataFunctions().getRequest(methodName: "DiaryWebMethod", parameters: paramString) { (result) -> () in
            for item in result {
                if item["Error"] != nil {
                    if (item["Error"] as? String == "501") {
                        SCLAlertView().showError("Unable to fetch appointments", subTitle: "Error 501 was raised. ")
                    } else {
                        SCLAlertView().showError("Unable to fetch appointments", subTitle: item["Error"] as! String)
                    }
                    return
                } else {
                    let e = TKCalendarEvent()
                    e.title = item["Title"] as? String
                    e.startDate = Date(jsonDate: item["StartDate"] as! String)! //item["StartDateTime"] as! Date
                    e.endDate = Date(jsonDate: item["EndDate"] as! String)! //item["StopDateTime"] as! Date
                    e.content = item["Summary"] as? String
                    e.isAllDay = false
                    e.eventColor = UIColor(r:40, g:86, b:131)
                    self.events.add(e)
                }
            }
        }
    }

 

Any ideas why this is the case?

0
Adrian
Telerik team
answered on 02 Dec 2016, 03:49 PM
Hello, Bob,

Could you send me a sample project with the dots issue so I could investigate it further? Thank you in advance for the cooperation.

Regards,
Adrian
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
Stuart
Top achievements
Rank 1
Answers by
Stuart
Top achievements
Rank 1
Adrian
Telerik team
Share this question
or