title: How to export file directly on OctoberCms
body: <p>I have create a custom page that looks like this so all function are custom. I wanted to know how to directly export the results that are shown on my table using my export button without having to redirect on the export page because the default function redirects you to the certain page and that's what I am avoiding in order to retrieve also the filters that and apply those on the export function.</p>
  <p>I have created a call <code>exportOrders</code> it has no function on the Controller yet because I have no idea what to do with it.
  <a href="https://i.stack.imgur.com/McMkY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McMkY.png" alt="enter image description here" /></a></p>
  <p>Controller .htm</p>
  <pre><code>&lt;?= Form::open(['class' =&gt; 'layout']) ?&gt;
  &lt;div class=&quot;filter-container&quot;&gt;
      &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;status-container column&quot;&gt;
              &lt;label for=&quot;status&quot;&gt;Status:&lt;/label&gt;
              &lt;select id=&quot;statusFilter&quot; class=&quot;form-control custom-select&quot; name=&quot;status&quot;&gt;
                  &lt;option value=&quot;none&quot; selected&gt;None&lt;/option&gt;
                  &lt;option value=&quot;processing&quot;&gt;Processing&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
          (...)
      &lt;/div&gt;
      &lt;button&gt;
      (...)
      &lt;/button&gt;
      &lt;button
          id=&quot;exportOrders&quot;
          type=&quot;submit&quot;
          data-request=&quot;onExportOrders&quot;
          data-hotkey=&quot;ctrl+s, cmd+s&quot;
          data-load-indicator=&quot;&lt;?= e(trans('backend::lang.form.saving')) ?&gt;&quot;
          class=&quot;btn btn-secondary&quot;&gt;
          Export
      &lt;/button&gt;
      
  &lt;/div&gt;
  
  &lt;div class=&quot;orders-table&quot;&gt;
      &lt;table class=&quot;table d-flex justify-content-center&quot;&gt;
          &lt;thead&gt;
              &lt;th&gt;Order ID&lt;/th&gt;
              &lt;th&gt;Product Name&lt;/th&gt;
              &lt;th&gt;Status&lt;/th&gt;
              &lt;th&gt;Payment Method&lt;/th&gt;
              &lt;th&gt;SKU&lt;/th&gt;
              &lt;th&gt;Total&lt;/th&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;?php foreach($orders as $data) {
                  # declare variables here
                  $id = $data['id'];
                  $status = $data['status'];
                  $payment_gateway = $data['payment_gateway'];
                  $total = $data['total'];
                  $sku = $data['sku'];
                  $product_name = $data['product_name'];
  
                  echo(&quot;&lt;tr&gt;
                          &lt;td&gt;&lt;a target='' href='/admin/xtendly/ecommerce/orders/update/$data[id]'&gt;$id&lt;/a&gt;&lt;/td&gt;
                          &lt;td&gt;$product_name&lt;/td&gt;
                          &lt;td&gt;$status&lt;/td&gt;
                          &lt;td&gt;$payment_gateway&lt;/td&gt;
                          &lt;td&gt;$total&lt;/td&gt;
                          &lt;td&gt;$sku&lt;/td&gt;
                      &lt;/tr&gt;&quot;);
              } ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;?= Form::close() ?&gt;
  </code></pre>
  <p>This is my Controller for handling the results</p>
  <pre><code>public $implement = [        
          'Backend\Behaviors\ListController',        
          'Backend\Behaviors\FormController',        
          'Backend\Behaviors\ReorderController'    
      ];
      
      public $listConfig = 'config_list.yaml';
      public $formConfig = 'config_form.yaml';
      public $reorderConfig = 'config_reorder.yaml';
  
      public function __construct()
      {
          parent::__construct();
          BackendMenu::setContext('X.Ecommerce', 'main-menu-item2');
      }
  
      public function partialRenderOrders()
      {
          $status = post('status');
          $payment = post('payment');
          
          $data = $this-&gt;getOrders($status, $payment);
          
          $params = [
              'orders' =&gt; $data,
          ];
  
          return $this-&gt;makePartial('orders', $params);
      }
  
      public function getOrders($status_ = null) {
          $query = Order::query();
  
          if($status_ !== &quot;none&quot; || $status_ == null) {
              $result = $query-&gt;where('status','LIKE','%'.$status_.'%')-&gt;get();
          } else {
              $result = $query-&gt;get();
          }
          
          $collection = collect($result-&gt;toArray());
          $data = $collection-&gt;map(function ($item) {
              if(is_array($item)) {
                  foreach($item as $key =&gt; $value) {
                      
                      //Order Details
                      if($key == 'order_details') {
                          $order_details = json_decode($value);
                          $sku_ = &quot;&quot;; $product_name = &quot;&quot;;
                          $last = count($order_details) - 1;
                          for($i = 0; $i &lt; count($order_details); $i++) {
                              if($last &gt; $i) {
                                  //sku
                                  $sku_.= isset($order_details[$i]-&gt;sku) &amp;&amp; $order_details[$i]-&gt;sku !== &quot;&quot; ? &quot;&quot;.strval($order_details[$i]-&gt;sku).&quot;, &quot; : '';
                                  //product name
                                  $product_name = isset($order_details[$i]-&gt;title) &amp;&amp; $order_details[$i]-&gt;title !== &quot;&quot; ? &quot;&quot;.strval($order_details[$i]-&gt;title).&quot;, &quot; : '';
                              } else {
                                  //sku
                                  $sku_.= isset($order_details[$i]-&gt;sku) &amp;&amp; $order_details[$i]-&gt;sku !== &quot;&quot; ? &quot;&quot;.strval($order_details[$i]-&gt;sku).&quot;&quot; : '';
                                  //product name
                                  $product_name.= isset($order_details[$i]-&gt;title) &amp;&amp; $order_details[$i]-&gt;title !== &quot;&quot; ? &quot;&quot;.strval($order_details[$i]-&gt;title).&quot;&quot; : '';
                              }
                          }
                          $item['sku'] = $sku_;
                          $item['product_name'] = $product_name;
                      }
                  }
              }
              return $item;
          });
          return $data;
      }
  
  </code></pre>
  <p>It would be a big help if you could provide me a good code since I'm quite new with OctoberCMS.</p>