Closed reenaphilip closed 4 years ago
I have two DateRow and a LabelRow. Based on the dates selected, I should update the date difference and update the LabelRow value.
<<< DateRow("FromDateRow"){ $0.title = "Period From" $0.value = Date()//formatter.string(from: Date()) $0.minimumDate = Date() }.onChange({ (row) in self.updateNoOfDaysRow() }) <<< DateRow("ToDateRow"){ $0.title = "Period To" $0.value = Date()//formatter.string(from: Date()) $0.minimumDate = Date() }.onChange({ (row) in self.updateNoOfDaysRow() }) <<< LabelRow("LeaveCountRow"){ $0.title = "Total Days" self.updateNoOfDaysRow() }
The code to update Label :
func updateNoOfDaysRow(){ guard let fromRow = self.form.rowBy(tag: "FromDateRow") as? DateRow else{ return } let fromDate = fromRow.value guard let toRow = self.form.rowBy(tag: "ToDateRow") as? DateRow else{ return } let toDate = toRow.value guard let countRow = self.form.rowBy(tag: "LeaveCountRow") as? LabelRow else{ return } countRow.value = String(describing: self.calculateNumberOfDays(fromDate: fromDate!, toDate: toDate!)) }
But the value is. not updating to the label. Do I need to reload the entire form? Please suggest.
Try running countRow.updateCell() after updating its value.
countRow.updateCell()
BTW you should use weak self in all those callbacks
Thank you. its working with updateCell().
Yes I will change to weak self.
I have two DateRow and a LabelRow. Based on the dates selected, I should update the date difference and update the LabelRow value.
The code to update Label :
But the value is. not updating to the label. Do I need to reload the entire form? Please suggest.