phpcodeignitercustom-actiongrocery-crud

How to open in a new window a custom action in grocery crud?


What I want to do is that when I click the custom action in a table rendered using grocery crud it will open in a new window.

public function list() {
        try {
            $crud = new grocery_CRUD();

            $crud->set_theme('flexigrid');
            $crud->set_table('employee');

            $crud->add_action('Create Payslip', base_url().'design/images/img.png', 'roll/emp');

            $output = $crud->render();

            $this->output($output);
        } catch(Exception $e) {
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
    }

What should I add?


Solution

  • You could modify the default grocery crud, to add a jquery handler (or you could add that using a callback if you prefer this for some reason).

    This jquery handler will make the links of some determined class ( for example the class attribute of an add_action generated button can be class="edit_button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" ) to open in a new window (target="_blank").

    Your handler will be something like this:

    //add here the class of the buttons you need to open links in a new window $(".YOUR_CLASS_NAME").attr("target", "_blank");