javalnanda / JNDropDownMenu

Swift version of https://github.com/dopcn/DOPDropDownMenu
MIT License
64 stars 8 forks source link

Enhancement request: set column title #5

Closed FleetPhil closed 7 years ago

FleetPhil commented 7 years ago

Hi - I have a use case where the drop down is a list of filter criteria for a list - each row can be selected or deselected by clicking on it and it has a tick or cross to indicate if it is selected (example below). I can update the row text dynamically and this works OK, but the column title is automatically set to the last selected item when I would like to be able to set it manually - with something like a function of JNDropDownMenu: func setTitle(_ title : String, forColumn: NSInteger) If not called it would default to the existing behaviour, but if present would set the column title to the specified value irrespective of the last item selected.

Let me know what you think - Thanks, Phil

screen shot 2017-05-09 at 22 37 57
javalnanda commented 7 years ago

@hotairforacoolbreeze Check out v 0.1.5. Updated as per your request :) Screenshot looks nice. Are you using unicode for tick mark and cross symbol?

FleetPhil commented 7 years ago

Thanks for the super quick response! Yes, these are Unicode 2713 and 2717 for the marks. Thanks Phil

javalnanda commented 7 years ago

You are welcome. Hope you are finding it useful for your project :)

FleetPhil commented 7 years ago

Sorry - it's not working - the column title is set when the menu is first set up but then back to the previous behaviour when a menu item is selected. I think the issue is in the line of code below where the title is reset after a selection is made... ` func confiMenuWith(row: NSInteger) {

    let title = self.titles[self.currentSelectedMenuIndex]

    if updateColumnTitleOnSelection {
        title.string = self.datasource?.titleForRow(at: JNIndexPath(column: self.currentSelectedMenuIndex, row: row), for: self)
    }

`

javalnanda commented 7 years ago

Are you setting this flag to false ? menu.updateColumnTitleOnSelection = false I have mentioned that in Readme in change log.

FleetPhil commented 7 years ago

Doh! Sorry I missed that - it's fine now, thanks!