on 04-28-2017 1:45 PM
I have followed the document as it is but always get an exception when I click on the cell to change value. Bad execution.
Also I have to long press in my simulator normal press does nothing.
Below is my code
var propValue7: [Int] = [0]
let valueOptions7 = ["YK ROADWAYS", "Transporter B", "Transporter C"]
let cell = tableView.dequeueReusableCell(withIdentifier: FUIListPickerFormCell.reuseIdentifier, for: indexPath) as! FUIListPickerFormCell
print(indexPath.row)
cell.isEditable = true
// cell.keyName = "\(order.vehicleType), \(order.vehicleRoute), \(order.totalWeight.round(1)), - \(order.noOfVehicles) vehicles"
// cell.value = "\(order.transporter)"
// let text = order.noOfVehicles == 1? "vehicle":"vehicles"
let vehicleString: String = order.noOfVehicles == 1 ? "vehicle":"vehicles"
cell.keyName = "\(order.vehicleType), \(order.vehicleRoute), \(order.totalWeight.round(1)), - \(order.noOfVehicles) \(vehicleString)"
cell.value = propValue7
cell.allowsMultipleSelection = false
cell.valueTextField.text = descriptionForSelectedStrings(valueOptions7, at: propValue7) // See below
cell.valueOptions = valueOptions7
cell.listPicker.dataSource = nil
print("\(cell.listPicker)")
// cell.listPicker.searchResultsUpdating = listPickerDataSource7
// cell.listPicker.isSearchEnabled = false
// cell.listPicker.prompt = "Please select multiple items"
// cell.delegate = DetailTableDelegate
// cell.listPicker.searchBar?.isBarcodeScannerEnabled = true
// cell.listPicker.searchBar?.barcodeScanner?.scanMode = .EAN_UPC
// cell.listPicker.searchBar?.barcodeScanner?.scanResultTransformer = { (scanString) -> String in
// return self.transformStringToSearchBar(scanResultString: scanString)
// }
// MARK: implement onChangeHandler
cell.onChangeHandler = { [unowned self] newValue in
propValue7 = newValue
}
Cant i use form cells without subclassing FUIFormTableViewController? Because my viewcontroller has to embed with UIview and a tableview
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As requested in the comments here is a "quick and dirty" implementation of the table view controller. Consider that I did remove some parts of your code (e.g. the setting of the cell.valueTextField.text property). You have to add adjust the coding for your requirements
import UIKit
import SAPFiori
class TableViewController: FUIFormTableViewController {
var propValue7: [Int] = [0]
var valueOptions7 = ["YK ROADWAYS", "Transporter B", "Transporter C"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(FUIListPickerFormCell.self, forCellReuseIdentifier: FUIListPickerFormCell.reuseIdentifier)
tableView.estimatedRowHeight = 80
tableView.rowHeight = UITableViewAutomaticDimension
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUIListPickerFormCell.reuseIdentifier, for: indexPath) as! FUIListPickerFormCell
print(indexPath.row)
cell.keyName = "Vehicles"
cell.value = propValue7
cell.allowsMultipleSelection = false
cell.valueTextField.text = "..."
cell.valueOptions = self.valueOptions7
cell.listPicker.prompt = "Please select a value"
cell.onChangeHandler = { [unowned self] newValue in
self.propValue7 = newValue
}
return cell
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, UIKit is not necessary in an explicit way.
If your table view controller inherits from FUIFormTableViewController, your table view controller is embedded in a navigation controller and if your coding matches than one like described in the documentation (or the dummy example above) it should work.
Have you defined the propValue7 variable locally in the tableview(:cellForRowAt) method or as property in the class? You have to define it as property in the class (or an object referenced by the class) so that it is available when the onChangeHandler method is executed.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It will work in such a way that you get no crash, but in case the propValue7 is locally defined, the selected value will not change.
But that you get also no the list with the values to be selected is an "nice" further information, which issue is not related to that.
Did you check if your table view controller implementation is inherited from class FUIFormTableViewController. If that is not the case you will get a crash in case you click on the cell in order to navigate to the value list.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.