Eureka: Refresh Values

Created on 20 Sep 2016  路  4Comments  路  Source: xmartlabs/Eureka

I've a background service for fetching data once he done I need to refresh my views so here's how I declare my form view:

            +++ Section()
                <<< TextRow() {
                    $0.disabled = true
                    $0.value = newPaySlip.remainingTimeOff
                }

Here my get data function :

    func getData() {
        PCServicesManager.getPaySlipBaseValue { (error, data) in
            if let data = data as? NSDictionary where error == .None {
                self.newPaySlip = PCPaySlip(dict: data)
                self.tableView?.reloadData()
            }
        }
    }

Nothing happen values are not updated after : self.tableView?.reloadData()

question

Most helpful comment

TextRow() {
        $0.tag = "yourRowTag"
        $0.disabled = true
        $0.value = newPaySlip.remainingTimeOff
    }

the previous closure is invoked on row initialisation time which means that even though you set up newPaySlip again the value will not be reflected int the form.

You will have to use setValues form method. Take a look at newPaySlip. Then reload the table view.

All 4 comments

Try self.form.rowByTag("yourRowTag")?.updateCell() instead of self.tableView?.reloadData()
and implement cellUpdate callback on your TextRow

func getData() {
    PCServicesManager.getPaySlipBaseValue { (error, data) in
        if let data = data as? NSDictionary where error == .None {
            self.newPaySlip = PCPaySlip(dict: data)
            self.form.rowByTag("yourRowTag")?.updateCell()
        }
    }
}

+++ Section()
    <<< TextRow() {
        $0.tag = "yourRowTag"
        $0.disabled = true
        $0.value = newPaySlip.remainingTimeOff
    }.cellUpdate { cell, row in
        row.options = self.newPaySlip
    }

Hope it help. It is working for PushRow.

TextRow() {
        $0.tag = "yourRowTag"
        $0.disabled = true
        $0.value = newPaySlip.remainingTimeOff
    }

the previous closure is invoked on row initialisation time which means that even though you set up newPaySlip again the value will not be reflected int the form.

You will have to use setValues form method. Take a look at newPaySlip. Then reload the table view.

@mtnbarreto avec setValues il faut utilise tableview.reloadData() refresher les valeurs ?

Similar issue:


            <<< ButtonRow() {
                    $0.title = ""
                    $0.tag = "buttonRow1"
                }  .cellSetup{ cell, row in
                    cell.imageView?.image = UIImage(data: self.imageData! as Data)         
                }
            .onCellSelection { cell, row in
                    self.handleSelectPhoto()  // function to display imagePicker for photos; this part works
                    cell.imageView?.image = UIImage(data: self.imageData! as Data)
                    self.form.rowBy(tag: "buttonRow1")?.updateCell()
                    self.tableView.reloadData()
                }.cellUpdate{cell, row in
                    cell.imageView?.image = UIImage(data: self.imageData! as Data)
                    self.tableView.reloadData()
            }

The value for self.imageData is updated correctly, but the image on the buttonRow once call back is finished, doesn't get updated until selecting on the button row a 2nd time. Should update once done with .onCellSelection finishes? Have also tried refreshing tableView directly inside handleSelectPhoto().

Ideally, on returning to form from imagePicker, the button image should upload with the new image.

Was this page helpful?
0 / 5 - 0 ratings