Dynamically change button icon and color?

Hi All,

I’ve read a few threads on here that come close to answering my question, but not exactly.

I have table with a Done button. I would like the default state to show a empty box and when clicked a checkbox and also have it update the Status column. When clicked, I would like the text on the button to say “reopen” and if clicked, have it reset the Status column to “In Progress”.

At the moment, the button works to set the date and time clicked, changing the text to “reopen” and updating the Status to done, but if I click it again, the status doesn’t change. I can’t figure out how to change the icons. Help!

Button code:
thisRow
.ModifyRows(
Buttons.ToggleState,
Not(thisRow.ToggleState),
Buttons.DoneDate,
Now(),
thisRow.Status, “Done”
)

Button label:
If(thisRow.ToggleState, “Reopen”, “Done”)

Table:

hi @Bradley_Skaggs

thanks for adding the sample doc

I removed the disable (via advanced) to respond to:

I can’t figure out how to change the icons. Help!

Does this respond to your question?

Cheers, Christiaan

Hi Christiaan,

Thanks for your help. That isn’t exactly the issue. What I want to happen is this:

Start by unclicking all buttons, then set the status to In progress. Now click on either your button or mine, and the Status will change to Done. Now, if you unclick either your button or mine, I would like the status to go back to In Progress. In other words, unclicking the button resets the status too.

Thanks,

—b

Hi @Bradley_Skaggs , I’ll have a look again. I did not expect to see a function driven select list, which cannot be manipulated by the button as you know.

it is or a button altering the status of you have a function doing the job, one or the other.

below my suggestion for the button

thisRow
  .ModifyRows(
    Buttons.ToggleState,
    thisRow.ToggleState.Not(),
    Buttons.DoneDate,
     Now(),
    thisRow.christiaan,
    SwitchIf(
      thisRow.christiaan.Contains([in progress]), done, 
      thisRow.christiaan.Contains(done),[in progress])
  )

Cheers, Christiaan

The only problem is that my status column has a SwitchIf() statement to keep people from selecting the wrong options based on if the task is done or not. In other words, once it’s done, there shouldn’t be any other status options to choose from.

SwitchIf(
thisRow.ToggleState=True,
List(“Done”),
thisRow.ToggleState=False,
List(“Not started”, “Scheduled”, “In progress”)
)

Hello @Bradley_Skaggs ,

I think what happened here is that this project got started, got modified, and then got modified again. At the end, there is not much left from what you started with.

I started by deleting what was there, read what you tried to accomplish, got rid if a couple of columns (they are hidden, but not used by my formulas.

I introduced one helper column to prevent people from manually messing with the status column and you should do the same with the DoneDate column (but you should be able to figure that out by yourself :slight_smile: .

I would never call the “ToggleBtn” a toggle, because that is confusing (coda has a checkbox/toggle that really is a toggle. The button can, if properly configured, have many more states than just 2 and can invoke actions (where a toggle only stores a state, it does not invoke an action).

Proper naming is going to help you to keep your thoughts aligned and your work structured.

The way you have set this up would not be my approach, but for the sake of showing you how to do what you where trying to do, I stuck to your setup.

And even the little bit of code in your button could have been written in a couple of different ways.

Happy coda-ing,
Greetings, Joost

1 Like

Yes, this has gone through a few variations. It was started mostly so I could learn, which I definitely am, so thank you.

The only issue with your solution is that the status menu can’t be changed if the button is not clicked done. I’m also curious how you would have set this up. I really don’t know what is the best practice, but it mad sense to me when I started :wink:

All I am trying to do is give the option that if a task is marked Done, it can be clicked again to to reopen it and reset the status. If it’s not clicked then the status needs to be able to be changed from Not Started, Scheduled or In Progress.

Thanks for your help!

@Bradley_Skaggs ,

I’m also curious how you would have set this up
Well, look at the formula in the button - no secrets there. I don’t know what to say, it is all there.
About changing the status by hand: no problem, but generally, when you set things with a button, you don’t want people to mess with it by manually changing what has just been set. For sure, someday someone will set a task as “done” without changing the date.

But, for the sake of showing you, I changed it the way you are asking. I think you should not allow for this, but, it’s your document!

1 Like

You are right, it doesn’t make any sense like this. Once the done button is clicked, then the other options in the dropdown need to disappear with only “Done” being the available option.

The idea is the button is clicked, it toggles the checkmark to “done” and sets the status option to “done” with no other options available (likewise, if the button is not clicked, then “done” is not an option in the status list).

Thanks for your help.

-b

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.