Filter columns with renderers but without an index












0















I'm adding a column like so in _prepareColumns() method of a class that extends Mage_Adminhtml_Block_Widget_Grid:



$this->addColumn('status', array(
'header' => $this->helper->__('Status'),
'width' => '20px',
'renderer' => 'namespace_modulename/adminhtml_renderer_status'
));


It doesn't have an index and the values for this column are being shown properly in the grid but I am not able to filter because filtering needs a column in select statement to exist.



How can I filter a custom column that its value is returned from a renderer and could be anything?










share|improve this question



























    0















    I'm adding a column like so in _prepareColumns() method of a class that extends Mage_Adminhtml_Block_Widget_Grid:



    $this->addColumn('status', array(
    'header' => $this->helper->__('Status'),
    'width' => '20px',
    'renderer' => 'namespace_modulename/adminhtml_renderer_status'
    ));


    It doesn't have an index and the values for this column are being shown properly in the grid but I am not able to filter because filtering needs a column in select statement to exist.



    How can I filter a custom column that its value is returned from a renderer and could be anything?










    share|improve this question

























      0












      0








      0








      I'm adding a column like so in _prepareColumns() method of a class that extends Mage_Adminhtml_Block_Widget_Grid:



      $this->addColumn('status', array(
      'header' => $this->helper->__('Status'),
      'width' => '20px',
      'renderer' => 'namespace_modulename/adminhtml_renderer_status'
      ));


      It doesn't have an index and the values for this column are being shown properly in the grid but I am not able to filter because filtering needs a column in select statement to exist.



      How can I filter a custom column that its value is returned from a renderer and could be anything?










      share|improve this question














      I'm adding a column like so in _prepareColumns() method of a class that extends Mage_Adminhtml_Block_Widget_Grid:



      $this->addColumn('status', array(
      'header' => $this->helper->__('Status'),
      'width' => '20px',
      'renderer' => 'namespace_modulename/adminhtml_renderer_status'
      ));


      It doesn't have an index and the values for this column are being shown properly in the grid but I am not able to filter because filtering needs a column in select statement to exist.



      How can I filter a custom column that its value is returned from a renderer and could be anything?







      magento-1.9 adminhtml grid renderer






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 16 at 13:48









      revorevo

      25510




      25510






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I think you will have to use the 'filter_condition_callback' key. You should start by searching for 'filter_condition_callback' occurences in the core code and you will find some example.



          For example, in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php.



          Briefly, you have to write something like




          'filter_condition_callback'=> array($this, '_filterWhatYouWantCondition')



          and create a protected function _filterWhatYouWantCondition






          share|improve this answer
























          • filter_condition_callback filters the collection. But I don't have them in collection.

            – revo
            Jan 16 at 17:37











          • Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

            – Julien Loizelet
            Jan 16 at 17:54











          • The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

            – revo
            Jan 16 at 17:57













          • Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

            – Julien Loizelet
            Jan 16 at 18:02











          • May you please show an example?

            – revo
            Jan 16 at 18:03











          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258033%2ffilter-columns-with-renderers-but-without-an-index%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









          0














          I think you will have to use the 'filter_condition_callback' key. You should start by searching for 'filter_condition_callback' occurences in the core code and you will find some example.



          For example, in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php.



          Briefly, you have to write something like




          'filter_condition_callback'=> array($this, '_filterWhatYouWantCondition')



          and create a protected function _filterWhatYouWantCondition






          share|improve this answer
























          • filter_condition_callback filters the collection. But I don't have them in collection.

            – revo
            Jan 16 at 17:37











          • Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

            – Julien Loizelet
            Jan 16 at 17:54











          • The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

            – revo
            Jan 16 at 17:57













          • Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

            – Julien Loizelet
            Jan 16 at 18:02











          • May you please show an example?

            – revo
            Jan 16 at 18:03
















          0














          I think you will have to use the 'filter_condition_callback' key. You should start by searching for 'filter_condition_callback' occurences in the core code and you will find some example.



          For example, in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php.



          Briefly, you have to write something like




          'filter_condition_callback'=> array($this, '_filterWhatYouWantCondition')



          and create a protected function _filterWhatYouWantCondition






          share|improve this answer
























          • filter_condition_callback filters the collection. But I don't have them in collection.

            – revo
            Jan 16 at 17:37











          • Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

            – Julien Loizelet
            Jan 16 at 17:54











          • The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

            – revo
            Jan 16 at 17:57













          • Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

            – Julien Loizelet
            Jan 16 at 18:02











          • May you please show an example?

            – revo
            Jan 16 at 18:03














          0












          0








          0







          I think you will have to use the 'filter_condition_callback' key. You should start by searching for 'filter_condition_callback' occurences in the core code and you will find some example.



          For example, in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php.



          Briefly, you have to write something like




          'filter_condition_callback'=> array($this, '_filterWhatYouWantCondition')



          and create a protected function _filterWhatYouWantCondition






          share|improve this answer













          I think you will have to use the 'filter_condition_callback' key. You should start by searching for 'filter_condition_callback' occurences in the core code and you will find some example.



          For example, in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php.



          Briefly, you have to write something like




          'filter_condition_callback'=> array($this, '_filterWhatYouWantCondition')



          and create a protected function _filterWhatYouWantCondition







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 16 at 17:29









          Julien LoizeletJulien Loizelet

          828314




          828314













          • filter_condition_callback filters the collection. But I don't have them in collection.

            – revo
            Jan 16 at 17:37











          • Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

            – Julien Loizelet
            Jan 16 at 17:54











          • The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

            – revo
            Jan 16 at 17:57













          • Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

            – Julien Loizelet
            Jan 16 at 18:02











          • May you please show an example?

            – revo
            Jan 16 at 18:03



















          • filter_condition_callback filters the collection. But I don't have them in collection.

            – revo
            Jan 16 at 17:37











          • Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

            – Julien Loizelet
            Jan 16 at 17:54











          • The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

            – revo
            Jan 16 at 17:57













          • Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

            – Julien Loizelet
            Jan 16 at 18:02











          • May you please show an example?

            – revo
            Jan 16 at 18:03

















          filter_condition_callback filters the collection. But I don't have them in collection.

          – revo
          Jan 16 at 17:37





          filter_condition_callback filters the collection. But I don't have them in collection.

          – revo
          Jan 16 at 17:37













          Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

          – Julien Loizelet
          Jan 16 at 17:54





          Well, a filter on a grid will be the result of a collection that has been filtered. As you are in the Mage_Adminhtml_Block_Widget_Grid block, you necessarily have a collection that you can get with $this->getCollection(). I guess you will have to find a way to filter this collection using the value returned by your renderer.

          – Julien Loizelet
          Jan 16 at 17:54













          The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

          – revo
          Jan 16 at 17:57







          The problem is I'm using some renderers that return things that don't relate to current collection. They receive $row which is an instance of Mage_Sales_Model_Order_Item and return something that isn't in collection. So I can't use collection to filter the results.

          – revo
          Jan 16 at 17:57















          Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

          – Julien Loizelet
          Jan 16 at 18:02





          Well, maybe you could modify the collection (in the _prepareCollection method for example) in order to put your "unrelated infos" in it. And then, you will be able to filter this collection depending on this "unrelated infos". It sounds tricky but I have no better idea.

          – Julien Loizelet
          Jan 16 at 18:02













          May you please show an example?

          – revo
          Jan 16 at 18:03





          May you please show an example?

          – revo
          Jan 16 at 18:03


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258033%2ffilter-columns-with-renderers-but-without-an-index%23new-answer', 'question_page');
          }
          );

          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







          Popular posts from this blog

          An IMO inspired problem

          Management

          Investment