How do I add a custom dropdown filter in a grid
This is my code:
$this->addColumn(
$key,
array(
header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
)
);
I want to get all of the values from my column and put it in the dropdown options values and to filter them. Is there a way to do that ? At the moment I got an empty dropdown.
[UPDATE]
For instance if my values are 2,3,2,3,4,5,6,7 . I want to have in my dropdown the following values: 2,3,4,5,6,7
[UPDATE 2]
I managed to put the values in the dropdown. See My code:
$this->addColumn(
$key,
array(
'header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
'renderer' => $render,
'type' => 'options',
'options' => $this->_getOrderType(),
)
);
public function _getOrderType(){
$types = new Varien_Object(array(
"Frontend" => "Frontend",
"AdminPanel" => "AdminPanel"
));
return $types->getData();
}
But my filter doesn't work. If I filter after smth I got an empty grid.
[UPDATE 3]
Update with the render function:
public function render(Varien_Object $row)
{
$value = $this->_getValue($row);
if ($value == ""){
return "Frontend";
}else {
return "AdminPanel";
}
}
magento-1 grid filter
add a comment |
This is my code:
$this->addColumn(
$key,
array(
header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
)
);
I want to get all of the values from my column and put it in the dropdown options values and to filter them. Is there a way to do that ? At the moment I got an empty dropdown.
[UPDATE]
For instance if my values are 2,3,2,3,4,5,6,7 . I want to have in my dropdown the following values: 2,3,4,5,6,7
[UPDATE 2]
I managed to put the values in the dropdown. See My code:
$this->addColumn(
$key,
array(
'header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
'renderer' => $render,
'type' => 'options',
'options' => $this->_getOrderType(),
)
);
public function _getOrderType(){
$types = new Varien_Object(array(
"Frontend" => "Frontend",
"AdminPanel" => "AdminPanel"
));
return $types->getData();
}
But my filter doesn't work. If I filter after smth I got an empty grid.
[UPDATE 3]
Update with the render function:
public function render(Varien_Object $row)
{
$value = $this->_getValue($row);
if ($value == ""){
return "Frontend";
}else {
return "AdminPanel";
}
}
magento-1 grid filter
add a comment |
This is my code:
$this->addColumn(
$key,
array(
header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
)
);
I want to get all of the values from my column and put it in the dropdown options values and to filter them. Is there a way to do that ? At the moment I got an empty dropdown.
[UPDATE]
For instance if my values are 2,3,2,3,4,5,6,7 . I want to have in my dropdown the following values: 2,3,4,5,6,7
[UPDATE 2]
I managed to put the values in the dropdown. See My code:
$this->addColumn(
$key,
array(
'header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
'renderer' => $render,
'type' => 'options',
'options' => $this->_getOrderType(),
)
);
public function _getOrderType(){
$types = new Varien_Object(array(
"Frontend" => "Frontend",
"AdminPanel" => "AdminPanel"
));
return $types->getData();
}
But my filter doesn't work. If I filter after smth I got an empty grid.
[UPDATE 3]
Update with the render function:
public function render(Varien_Object $row)
{
$value = $this->_getValue($row);
if ($value == ""){
return "Frontend";
}else {
return "AdminPanel";
}
}
magento-1 grid filter
This is my code:
$this->addColumn(
$key,
array(
header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
)
);
I want to get all of the values from my column and put it in the dropdown options values and to filter them. Is there a way to do that ? At the moment I got an empty dropdown.
[UPDATE]
For instance if my values are 2,3,2,3,4,5,6,7 . I want to have in my dropdown the following values: 2,3,4,5,6,7
[UPDATE 2]
I managed to put the values in the dropdown. See My code:
$this->addColumn(
$key,
array(
'header' => Mage::helper('core')->__($key),
'index' => $key,
'filter' => 'adminhtml/widget_grid_column_filter_select',
'sortable' => true,
'renderer' => $render,
'type' => 'options',
'options' => $this->_getOrderType(),
)
);
public function _getOrderType(){
$types = new Varien_Object(array(
"Frontend" => "Frontend",
"AdminPanel" => "AdminPanel"
));
return $types->getData();
}
But my filter doesn't work. If I filter after smth I got an empty grid.
[UPDATE 3]
Update with the render function:
public function render(Varien_Object $row)
{
$value = $this->_getValue($row);
if ($value == ""){
return "Frontend";
}else {
return "AdminPanel";
}
}
magento-1 grid filter
magento-1 grid filter
edited Jul 6 '16 at 13:20
Attila Naghi
asked Jul 6 '16 at 12:22
Attila NaghiAttila Naghi
374418
374418
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I am not sure where the values come from, but you can use native's php array_unique
function on the array of values, so the options would be unique.
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your$render
variable? Can you update the post with the renderer?
– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
|
show 2 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f124488%2fhow-do-i-add-a-custom-dropdown-filter-in-a-grid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am not sure where the values come from, but you can use native's php array_unique
function on the array of values, so the options would be unique.
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your$render
variable? Can you update the post with the renderer?
– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
|
show 2 more comments
I am not sure where the values come from, but you can use native's php array_unique
function on the array of values, so the options would be unique.
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your$render
variable? Can you update the post with the renderer?
– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
|
show 2 more comments
I am not sure where the values come from, but you can use native's php array_unique
function on the array of values, so the options would be unique.
I am not sure where the values come from, but you can use native's php array_unique
function on the array of values, so the options would be unique.
edited Jul 6 '16 at 12:57
Rushvi
2,4091729
2,4091729
answered Jul 6 '16 at 12:44
Wladyslaw BrodskyWladyslaw Brodsky
617
617
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your$render
variable? Can you update the post with the renderer?
– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
|
show 2 more comments
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your$render
variable? Can you update the post with the renderer?
– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
can you check my post again, i made some updates. thx
– Attila Naghi
Jul 6 '16 at 12:49
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/…
– Wladyslaw Brodsky
Jul 6 '16 at 13:08
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :)
– Attila Naghi
Jul 6 '16 at 13:14
What is your
$render
variable? Can you update the post with the renderer?– Wladyslaw Brodsky
Jul 6 '16 at 13:17
What is your
$render
variable? Can you update the post with the renderer?– Wladyslaw Brodsky
Jul 6 '16 at 13:17
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
Check now I did . If my row is empty show Frontend otherwise show Adminpanel
– Attila Naghi
Jul 6 '16 at 13:21
|
show 2 more comments
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f124488%2fhow-do-i-add-a-custom-dropdown-filter-in-a-grid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown