⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Bootstrap theme: print and column ordering



Vitor Fonseca

Vitor Fonseca
  • profile picture
  • Member

Posted 27 October 2020 - 16:41 PM

Hi,

 

 

With bootstrap theme when i print the table the atual column ordering is ignored.

Is this the default behaviour?

 

I edited gcrud.datagrid.js and added this in Datagrid.prototype.listenerPrintButton function

Datagrid.prototype.listenerPrintButton = function () {
		...

			var order_by = $('.column-with-ordering.active:first').data('order-by'),order_direction = '';

			if ($('.column-with-ordering.active:first').hasClass('ordering-desc')) {
				order_direction = 'desc';
			} else if ($('.column-with-ordering.active:first').hasClass('ordering-asc')) {
				order_direction = 'asc';
			}
			
			form_input_html += '<input type="hidden" name = "order_by[]" value="' + order_by + '"/>';
			form_input_html += '<input type="hidden" name = "order_by[]" value="' + order_direction + '"/>';



			form_on_demand = $("<form/>").attr("method", "post").attr("action", print_url).html(form_input_html);
...

and now it's working.

 

Grocery_CRUD.php doesn't need to be changed, because function getStateInfo already has

case 17: //print
                $state_info = (object)array();
                $data = !empty($_POST) ? $_POST : $_GET;

          ...

                if(!empty($data['order_by'][0]))
                {
                    $state_info->order_by = $data['order_by'];
                }
          ...