Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColumnStatus not working for some reason #1046

Open
matronator opened this issue Sep 16, 2022 · 1 comment
Open

ColumnStatus not working for some reason #1046

matronator opened this issue Sep 16, 2022 · 1 comment

Comments

@matronator
Copy link

matronator commented Sep 16, 2022

I have a grid where I need to show two status columns. One is from a varchar/string column (this one works) and the other one is from a bool/tinyint column with numeric index keys and the second one for some reason just won't work. When looking at the generated HTML, it seems to have everything EXCEPT for the button to toggle the dropdown.

This is the code:

$grid->addColumnStatus('enabled', 'Status')
->setCaret(true)
->addOption(1, 'Enabled')
	->setIcon('check')
	->setClass('btn-success')
	->endOption()
->addOption(0, 'Disabled')
	->setIcon('close')
	->setClass('btn-danger')
	->endOption()
->onChange[] = [$this, 'setStatus'];

$grid->addColumnStatus('value', 'Value')
->setOptions(array_map(function($item) {
	return ucfirst($item);
}, MY_CLASS::VALUES))
->onChange[] = [$this, 'setValue'];

And this is the result:

Snímek obrazovky 2022-09-16 v 17 59 08

I tried setting the options with an array instead like in the second one, but it didn't change anything. Why is it not working? Is it maybe the numeric index keys that are causing it?

@ikeblaster
Copy link
Contributor

ikeblaster commented Aug 21, 2023

It's caused by strict comparison in ColumnStatus::getCurrentOption. In your case you should be able to modify your code to addOption(true, 'Enabled') etc. and it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants