# Table Overview

# columns ( columns, reverse )

Sets the columns that you want to see in the review table. Takes a string, separated by commas, or an array of values. The second optional parameter causes the function to do the opposite, ie hides the selected columns. Takes tru / false, default false.

$xcrud->columns('name,email,city');
//or
$xcrud->columns(array('name','email','city'));
 
// hide columns
$xcrud->columns('name,email,city', true);

# order_by ( name, direction )

Sets the initial sorting of the table, take the field and sort order. By default - in ascending order ('asc').

$xcrud->order_by('name','desc');

# label ( fieldname, your_label )

Allows you to specify the name of your columns and fields, takes the field and the field name or an array.

$xcrud->label('name','Your Name');
//or
$xcrud->label(array('name' => 'Your Name'));

# column_name( fieldname, your_label )

The same as label(), but affects only on columns in grid.

# show_primary_ai_column ( bool )

Takes true / false, setting the display of primary auto-increment columns in the overview table.

$xcrud->show_primary_ai_column(true);

# limit ( int )

Sets the initial limit for display tables, takes an integer in the first argument. The value set by this function is always available in the list to select the number of lines per page.

$xcrud->limit(25);

# limit_list ( string_or_array )

Specifies a list of values ​​for the limits list. Takes an array of values, or string. Option 'all' lift a moderate amount of a result (display all rows).

$xcrud->limit_list('5,10,15,all');
//or
$xcrud->limit_list(array('5','10','15','all'));

# table_name ( name, tooltip, tooltip_icon )

Changes the name of the table in the title, takes a string as the first parameter, tooltip text in second parameter (optional) and tooltip icon name in 3rd (optional)

See 'default' theme icons

$xcrud->table_name('My custom table!');
$xcrud->table_name('My custom table!', 'Some tooltip text');
$xcrud->table_name('My custom table!', 'Some tooltip text','icon-leaf');

# unset_add( true )

Hides add button from list view.

$xcrud->unset_add();

# unset_edit( true )

Hide edit button from list view.

$xcrud->unset_edit();

# unset_view( true )

Hides view button from list view.

$xcrud->unset_view();

# unset_remove( true )

Hide remove button from list view.

$xcrud->unset_remove();

# unset_csv( true )

Hides csv-export button from list view.

$xcrud->unset_csv();

# unset_search( true )

Hides search feature.

$xcrud->unset_search();

# unset_print( true )

Hides printout feature.

$xcrud->unset_print();

# unset_title( true )

Hides table title.

$xcrud->unset_title();

# unset_numbers( true )

Hides rows numbers.

$xcrud->unset_numbers();

# unset_pagination( true )

Hides pagination

$xcrud->unset_pagination();

# unset_limitlist( true )

Hides list with limits buttons or dropdown

$xcrud->unset_limitlist();

# unset_sortable( true )

Makes columns unsortable

$xcrud->unset_sortable();

# unset_list( true )

Turn of grid view. Only details can be viewed or edited. Don't forget to set view parameter in render() method.

$xcrud->unset_list();

# unset_view(), unset_edit(), unset_remove(), duplicate_button()

These methods can get additional condition parameters (with {field_tags})

$xcrud->unset_edit(true,'username','=','admin'); // 'admin' row can't be editable

# remove_confirm( true )

Removes confirmation window on remove action. Takes true / false in the first parameter.

$xcrud->remove_confirm(false);

# start_minimized ( true )

Start xCRUD instance minimized. Takes true / false in the first parameter.

$xcrud->start_minimized(true);

# benchmark ( true )

Displays information about the performance in the lower right corner of the xCRUD window. Takes true / false in the first parameter.

$xcrud->benchmark(true);

# column_cut ( int, [fields] )

Sets the maximum number of characters to be displayed in columns. Takes an integer value in the first parameter. In the second parameter you can define target field(s)

$xcrud->column_cut(30); // all columns
$xcrud->column_cut(30,'title,description'); // separate columns

# duplicate_button ( true )

Show duplicate button. You can duplicate only the records in those tables that have auto-incremental primary field, and have no other unique indexes. Otherwise you will get an error.

$xcrud->duplicate_button();

Creates label for links in grid view. Takes new label in first parameter

$xcrud->links_label('home url');
// or
$xcrud->links_label('<i class="icon-home"></i>'); // bootstrap icon for bootstrap theme

# emails_label( label )

Creates label for links in grid view. Takes new label in first parameter

$xcrud->emails_label('Contact email');

# sum ( columns, classname, custom_data )

Calculates sum for columns and shows result row in the bottom of table. Calculates sum of the entire list, regardless of pagination. Takes columns list in first parameter, optional classname in second, and optional custom text pattern in third.

$xcrud->sum('price,fee,quantity');
//or
$xcrud->sum(array('price','fee','quantity'));
//or
$xcrud->sum('price','align-center','Total price is {value}'); // use {value} tag to get sum value in pattern

Adds custom link in grid, like edit or remove. You can define url in first parameter (required), name (optional) in 2nd, icon(optional) in 3rd, class attribute (optional) in 4th, additional button attributes (assoc array) as 5th.

For icon field you must use predefined classes, this is Icon glyphs for bootstrap theme (e.g. icon-glass, icon-music...). Also see 'default' theme icons for default theme.

$xcrud->button('http://example.com');
$xcrud->button('http://example.com','My Title','icon-link','',array('target'=>'_blank'));
 
// {column_tags} usage:
$xcrud->button('http://example.com/{user_id}/?token={user_token}');

TIP

You can use buttons with text labels. See $button_labels parameter in configuration file

Also button() supports simple condition in 6th parameter. Condition value supports {field_tags}. Example:

// show button whith link from 'link' field when 'link' field is not empty
$xcrud->button('{link}','userlink','link','','',array('link','!=','')); 

# highlight( field, operator, value, color, classname )

Adds background color or class attribute for grid cell based on user's condition.

$xcrud->highlight('orderNumber','=','10101','red');
$xcrud->highlight('orderNumber','>=','10113','#87FF6C');
$xcrud->highlight('city','=','Madrid','','main-city'); // you can define class attribute

Also you can get value from current row using {field_tag}

$xcrud->highlight('sum', '>', '{profit}', 'red');

# highlight_row( field, operator, value, color, classname )

The same as highlight(), but full row will be highlighted

# column_class( column(s), classname )

adds class atribute to column(s).

Parameters

  • classname - can any of the following predefined classes: align-left, align-right, align-center, font-bold, font-italic, text-underline
$xcrud->column_class('price,sum,count', 'align-center');

# subselect( column_name, query, before_column )

Select to other table with parameters. This will create new column and inserts it after last column in table, or before colum defined in 3rd parameter

//subselect
$xcrud->subselect('Order total','SELECT SUM(priceEach) FROM orderdetails WHERE orderNumber = {orderNumber}'); // insert as last column
$xcrud->subselect('Products count','SELECT COUNT(*) FROM orderdetails WHERE orderNumber = {orderNumber}','status'); // insert this column before 'status' column

// you can use order() and change_type() for this columns;
$xcrud->change_type('Order total','price','',array('prefix'=>'$'));
$xcrud->order_by('Products count');

Also you can operate with fields only in current row

$xcrud->subselect('Sum','{price}*{qty}');

Shows cell info in modal. See 'default' theme icons

$xcrud->modal('customerName,customerDescription);
$xcrud->modal('customerName', 'icon-user');
$xcrud->modal(array('customerName'=>'icon-user'));

# column_pattern(column_name, pattern_code)

Replaces default column cell output by custom pattern. Pattern can contain {field_tags} and {value} tag (value of current column)

$xcrud->column_pattern('username','My name is {value}');

Difference between {value} and {username} (see example): {username} will return raw value from current cell, but {value} will return full output if your field has some extra features (like image or formatted price)

# field_tooltip( field(s), tooltip_text [, icon ] )

Creates tooltip icon for field label in create/edit/view mode. See 'default' theme icons

$xcrud->field_tooltip('productName','Enter product name here');

# column_tooltip( column(s), tooltip_text [, icon ] )

Creates tooltip icon for column label in create/edit/view mode. See 'default' theme icons

$xcrud->field_tooltip('productName','Enter product name here');

# search_columns( [ column(s) ] [, default_column ] )

Defines column list for search and default search column

$xcrud->search_columns('productVendor,quantityInStock,buyPrice','quantityInStock');

# buttons_position( position )

Changes position of grid buttons. Can be 'left', 'right' or 'none'. 'None' option will hide buttons, their features will be available (unlike of unset_ methods). Default is 'right' and can be changed in configuration file.

$xcrud->buttons_position('left');

# hide_button( button_name(s) )

Hides system or your custom button ( defined with render_button() method ). This not disables button feature (unlike of unset_ methods).

$xcrud->hide_button('save_return');

Default system buttons are: view, edit, remove, duplicate, add, csv, print, save_new, save_edit, save_return, return.

# column_width( column(s), width )

Sets width of xcrud columns manualy.

$xcrud->column_width('description','65%');
$xcrud->column_width('first_name,last_name','100px'); 
Last Updated: 3/11/2021, 5:43:48 PM