0

I have below code.

magento\app\code\Custom\Module\Block\Adminhtml\Index.php

protected function _construct() {
    $this->addButton('select', array(
        'before_html' => '<form name="frm" id="frm" method="post" action=""><input name="form_key" type="hidden" value="' . $this->getFormKey() . '"/>',
        'label' => __('Select'),
        'type' => 'submit',
        'name' => 'select',
        'id' => 'select',
        'value' => 1,
        'after_html' => '</form>',
    ));
}

magento\app\code\Custom\Module\Block\Adminhtml\Module\Grid.php

 protected function _prepareColumns() {

    $this->addColumn(
                    'id', [
                'header_css_class' => 'a-center',
                'type' => 'checkbox',
                'name' => 'id',
                'align' => 'center',
                'index' => 'id',
                'values' => array(3,4),
                    ]
            );

    $this->addColumn(
                    'qty_succeed[]', [
                'header' => __('Qty'),
                'type' => 'input', // Change to Input
                'index' => 'qty_succeed',
                'editor' => 'text',
                    ]
            );          
 }

I'm not using _prepareMassaction function as I'm not able to achieve needed functionality.

When clicked on "Select" button it should pass all values in Array so I can validate in Controller.

Question 1 How to add form on listing portion only? Because _prepareMassaction is not taking textbox values. It only takes checkbox values

Question 2 How to select main checkbox as well from Listing?

enter image description here

0

For both mass action and regular button you can use javascript to trigger a function, which can then collect whatever form values you want and submit them to server. This is the simplest way to go in this case.

  • But there is no Form within the listing portion. How to add form so it takes textbox value as well – Ankit Shah Mar 28 '17 at 8:48
  • To collect inputs values you don't need a form, all you need is something like: $('div.your_listing_class input[type=text]').each( function(){ return $(this).val() }) – Petar Dzhambazov Mar 28 '17 at 8:52
  • I need row wise things Checkbox with Texbox value so I can put on 'onclick' event of button – Ankit Shah Mar 28 '17 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.