How to pre-select a radio button in custom grid (Magento 1)

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Absorbing damage with Planeswalker

Why did Luke use his left hand to shoot?

Is there any risk in sharing info about technologies and products we use with a supplier?

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Variable is not visible

Why would space fleets be aligned?

A Missing Symbol for This Logo

How does Leonard in "Memento" remember reading and writing?

How do I draw the dashed lines as shown in this figure

How to tell if a BJT is PNP or NPN by looking at the circuit?

Clues on how to solve these types of problems within 2-3 minutes for competitive exams

What is the proper way to reproach a rav?

Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?

Which communication protocol is used in AdLib sound card?

What is a good reason for every spaceship to carry a weapon on board?

Is Krishna the only avatar among dashavatara who had more than one wife?

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

ST_Buffer in PostGIS produces different results for the same set of lines

What is the wife of a henpecked husband called?

Consequences of lack of rigour

What is the difference between rolling more dice versus fewer dice?

Avoid page break between paragraphs

Constexpr if with a non-bool condition



How to pre-select a radio button in custom grid (Magento 1)














0















I'm having trouble figuring out how to load a custom grid with a radio button pre-selected.



For example, I added a custom "Tax Class" tab to the Admin Product Edit page, with a grid that loads the tax/class collection.



I already know the current product's assigned tax_class_id, Mage::registry('product')->getTaxClassId(), I just need to figure out how to select that corresponding row in the grid.



Any ideas are much appreciated, relevant code snippet below:



class Kmdsax_ProductTaxClassTab_Block_Adminhtml_Catalog_Product_Tab 
extends Mage_Adminhtml_Block_Widget_Grid
implements Mage_Adminhtml_Block_Widget_Tab_Interface {

public function __construct()
{
parent::__construct();
$this->setId('taxClassGrid');
$this->setDefaultSort('class_name');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}

protected function _prepareCollection()
{
$collection = Mage::getModel('tax/class')
->getCollection()
->setClassTypeFilter('PRODUCT');

//$product = Mage::registry('product');
//$taxClassId = $product->getTaxClassId();

$this->setCollection($collection);
return parent::_prepareCollection();
}

protected function _prepareColumns()
{
$this->addColumn('tax_class_id', array(
'header' => Mage::helper('adminhtml')->__('Selected'),
'type' => 'radio',
'html_name' => 'taxClassId',
'align' => 'center'
));
$this->addColumn('op_avatax_code',
array(
'header' => Mage::helper('tax')->__('Avatax Code'),
'align' => 'left',
'index' => 'op_avatax_code'
)
);
$this->addColumn('class_name',
array(
'header' => Mage::helper('tax')->__('Class Name'),
'align' => 'left',
'index' => 'class_name'
)
);

return parent::_prepareColumns();
}








share



























    0















    I'm having trouble figuring out how to load a custom grid with a radio button pre-selected.



    For example, I added a custom "Tax Class" tab to the Admin Product Edit page, with a grid that loads the tax/class collection.



    I already know the current product's assigned tax_class_id, Mage::registry('product')->getTaxClassId(), I just need to figure out how to select that corresponding row in the grid.



    Any ideas are much appreciated, relevant code snippet below:



    class Kmdsax_ProductTaxClassTab_Block_Adminhtml_Catalog_Product_Tab 
    extends Mage_Adminhtml_Block_Widget_Grid
    implements Mage_Adminhtml_Block_Widget_Tab_Interface {

    public function __construct()
    {
    parent::__construct();
    $this->setId('taxClassGrid');
    $this->setDefaultSort('class_name');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
    $this->setUseAjax(true);
    }

    protected function _prepareCollection()
    {
    $collection = Mage::getModel('tax/class')
    ->getCollection()
    ->setClassTypeFilter('PRODUCT');

    //$product = Mage::registry('product');
    //$taxClassId = $product->getTaxClassId();

    $this->setCollection($collection);
    return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
    $this->addColumn('tax_class_id', array(
    'header' => Mage::helper('adminhtml')->__('Selected'),
    'type' => 'radio',
    'html_name' => 'taxClassId',
    'align' => 'center'
    ));
    $this->addColumn('op_avatax_code',
    array(
    'header' => Mage::helper('tax')->__('Avatax Code'),
    'align' => 'left',
    'index' => 'op_avatax_code'
    )
    );
    $this->addColumn('class_name',
    array(
    'header' => Mage::helper('tax')->__('Class Name'),
    'align' => 'left',
    'index' => 'class_name'
    )
    );

    return parent::_prepareColumns();
    }








    share

























      0












      0








      0








      I'm having trouble figuring out how to load a custom grid with a radio button pre-selected.



      For example, I added a custom "Tax Class" tab to the Admin Product Edit page, with a grid that loads the tax/class collection.



      I already know the current product's assigned tax_class_id, Mage::registry('product')->getTaxClassId(), I just need to figure out how to select that corresponding row in the grid.



      Any ideas are much appreciated, relevant code snippet below:



      class Kmdsax_ProductTaxClassTab_Block_Adminhtml_Catalog_Product_Tab 
      extends Mage_Adminhtml_Block_Widget_Grid
      implements Mage_Adminhtml_Block_Widget_Tab_Interface {

      public function __construct()
      {
      parent::__construct();
      $this->setId('taxClassGrid');
      $this->setDefaultSort('class_name');
      $this->setDefaultDir('ASC');
      $this->setSaveParametersInSession(true);
      $this->setUseAjax(true);
      }

      protected function _prepareCollection()
      {
      $collection = Mage::getModel('tax/class')
      ->getCollection()
      ->setClassTypeFilter('PRODUCT');

      //$product = Mage::registry('product');
      //$taxClassId = $product->getTaxClassId();

      $this->setCollection($collection);
      return parent::_prepareCollection();
      }

      protected function _prepareColumns()
      {
      $this->addColumn('tax_class_id', array(
      'header' => Mage::helper('adminhtml')->__('Selected'),
      'type' => 'radio',
      'html_name' => 'taxClassId',
      'align' => 'center'
      ));
      $this->addColumn('op_avatax_code',
      array(
      'header' => Mage::helper('tax')->__('Avatax Code'),
      'align' => 'left',
      'index' => 'op_avatax_code'
      )
      );
      $this->addColumn('class_name',
      array(
      'header' => Mage::helper('tax')->__('Class Name'),
      'align' => 'left',
      'index' => 'class_name'
      )
      );

      return parent::_prepareColumns();
      }








      share














      I'm having trouble figuring out how to load a custom grid with a radio button pre-selected.



      For example, I added a custom "Tax Class" tab to the Admin Product Edit page, with a grid that loads the tax/class collection.



      I already know the current product's assigned tax_class_id, Mage::registry('product')->getTaxClassId(), I just need to figure out how to select that corresponding row in the grid.



      Any ideas are much appreciated, relevant code snippet below:



      class Kmdsax_ProductTaxClassTab_Block_Adminhtml_Catalog_Product_Tab 
      extends Mage_Adminhtml_Block_Widget_Grid
      implements Mage_Adminhtml_Block_Widget_Tab_Interface {

      public function __construct()
      {
      parent::__construct();
      $this->setId('taxClassGrid');
      $this->setDefaultSort('class_name');
      $this->setDefaultDir('ASC');
      $this->setSaveParametersInSession(true);
      $this->setUseAjax(true);
      }

      protected function _prepareCollection()
      {
      $collection = Mage::getModel('tax/class')
      ->getCollection()
      ->setClassTypeFilter('PRODUCT');

      //$product = Mage::registry('product');
      //$taxClassId = $product->getTaxClassId();

      $this->setCollection($collection);
      return parent::_prepareCollection();
      }

      protected function _prepareColumns()
      {
      $this->addColumn('tax_class_id', array(
      'header' => Mage::helper('adminhtml')->__('Selected'),
      'type' => 'radio',
      'html_name' => 'taxClassId',
      'align' => 'center'
      ));
      $this->addColumn('op_avatax_code',
      array(
      'header' => Mage::helper('tax')->__('Avatax Code'),
      'align' => 'left',
      'index' => 'op_avatax_code'
      )
      );
      $this->addColumn('class_name',
      array(
      'header' => Mage::helper('tax')->__('Class Name'),
      'align' => 'left',
      'index' => 'class_name'
      )
      );

      return parent::_prepareColumns();
      }






      magento-1.9





      share












      share










      share



      share










      asked 37 secs ago









      kmdsaxkmdsax

      41838




      41838






















          0






          active

          oldest

          votes











          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%2f263757%2fhow-to-pre-select-a-radio-button-in-custom-grid-magento-1%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f263757%2fhow-to-pre-select-a-radio-button-in-custom-grid-magento-1%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

          “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

          How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

          變成蝙蝠會怎樣? 參考資料 外部連結 导航菜单Thomas Nagel, "What is it like to be a...