How can I save a records of the my Grid to a file?

Discussion in 'Customization & add-ons' started by mironovs, Jan 19, 2013.

  1. mironovs

    mironovs New Member

    Joined:
    Jan 3, 2013
    Messages:
    17
    Hello.

    Record filled with Query and shown to the client in a table. With the filter, it can filter the records in the table.


    Code:
    class My_GridController extends Am_Controller
    {
        function indexAction()
        {
            $grid = new Am_My_Grid_Member($this->_request, $this->view);
            $grid->runWithLayout('layout.phtml');
        }
    }

    Necessary for the customer to save the filtered records in the file. How can this be done?

    Thank you.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You should add export action to your grid:
    PHP:
     $grid = new Am_My_Grid_Member($this->_request$this->view);
     
    $action = new Am_Grid_Action_Export();
            
    $action->addField(new Am_Grid_Field('fieldname1'___('Field Title1')))
                      ->
    addField(new Am_Grid_Field('fieldname2'___('Field Title2')));
            
    $grid->actionAdd($action);
  3. mironovs

    mironovs New Member

    Joined:
    Jan 3, 2013
    Messages:
    17
    Hello Alexander.

    Thank you. But
    actionAdd
    available on class Am_Grid_Editable.
    I do not need to edit, delete, or adds a record with her. Is there any way to remove action "New Record" and a column with the elements remove / edit records?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Am_Grid_Editable has method public function initActions() which add above actions. You just need to override it.

Share This Page