# Table Overview

# benchmark()

Displays information about the performance in the lower right corner of the xCRUD window.

Parameter Type Default Description
$bool bool true Set true to display benchmarking info, false to turn off benchmarking info, if already set to show.
$xcrud->benchmark();
$xcrud->benchmark(false); // undo action above

# button()

Adds custom link button in grid view, just like the edit or remove buttons.

Parameter Type Default Description
$link string URL to open.
$name string '' HTML Button name.
$icon string '' Predefined classname. These are icon glyphs from the bootstrap theme. See default theme icons here: xcrud/themes/default/fonts.css (opens new window)
$class string '' CSS classname.
$parameters array array() Additional HTML attributes specified as an associative array with keys named after html attributes.
$condition array array() If specified, the array should have 3 items array(field,operand,value).
The field, operand, value are the same as for unset_edit().
If the condition is met i.e. true, the button is displayed.
$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}');

// last param $condition array('send_email','=',1)
// show button if field:send_email is equal to 1
$xcrud->button( '#', 'Send Email', 'icon-link', '', 
    array('class' => 'ajax-send', 'data-id' => '{paymentId}'), 
    array('send_email','=',1));

TIP

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

# button() {column} tags usage:

A column tag is a table fieldname (column) enclosed by curly braces i.e. '{fieldname}'.

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

# buttons_position()

Changes position of grid buttons. Can be 'left', 'right' or 'none'.

Parameter Type Default Description
$position string 'left' Accepted values are: 'left', 'right' or 'none'. Defaults to the 'right' side.
The 'none' option hides the buttons but their features are still be available, unlike the unset_* methods.
$xcrud->buttons_position('left');

# column_class()

Adds a HTML class atribute to column(s).

Parameters

  • 
    
Parameter Type Default Description
$columns string ''
$class string '' CSS class name(s) separated by space characters. Predefined classes include: 'align-left align-right align-center font-bold font-italic text-underline'.
$xcrud->column_class('price,sum,count', 'align-center teal');

# column_cut()

Sets the maximum number of characters to be displayed in columns.

Parameter Type Default Description
$int int 50 No. of characters to display. If the only parameter set, this applied to all columns. Date fields are not affected.
$fields string false Comma separated string of column names that will be limited to $int characters.
$safe_output bool false Encodes special characters to html-entities in grid view. Modern browsers IGNORE this value.
// all column data truncated at 30 chars
$xcrud->column_cut(30); 
// only title & description columns will be truncated to 30 characters.
$xcrud->column_cut(30,'title,description');    

# column_name()

List screen only. Set grid column header names. Make multiple calls for each field.

Parameter Type Default Description
$fields string '' Table field name.
$text string '' Field name alias.
$xcrud->column_name('name','Your Name'); 

# 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)

Parameter Type Default Description
$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)

# column_tooltip()

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

Parameter Type Default Description
$fields string '' Comma separated string of table field names or an array of field names.
$tooltip string '' The tooltip text to show on mouse hover over the $icon.
$icon string false Predefined classname. See default theme icons here: xcrud/themes/default/fonts.css (opens new window). If no $icon is specified, the class .icon-question is used, displaying a question mark.
$xcrud->column_tooltip('productName','Enter product name here');
// with icon
$xcrud->column_tooltip('surname','Family name', 'icon-leaf');

# column_width( column(s), width)

Sets width of xcrud columns manualy.

Parameter Type Default Description
$xcrud->column_width('description','65%');
$xcrud->column_width('first_name,last_name','100px'); 

# columns()

Set table field names to display.

Parameter Type Default Description
$columns mixed '' Comma separated string of table field names or an array of field names.
$reverse boolean false Hides the field names in $columns if set to true.
$xcrud->columns('name,email,city');
//or
$xcrud->columns(array('name','email','city'));
 
// hide columns
$xcrud->columns('name,email,city', true);

# duplicate_button()

Same parameters as unset_edit(). Show the duplicate buttons for all rows in list view. It can also show the duplicate buttons per row given a condition.

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(); // hide all delete buttons for each row
$xcrud->duplicate_button(false); // undo action above

// show duplicate buttons on rows that meet the condition 
// 'postalCode = 10022'
$xcrud->duplicate_button(true, 'postalCode', '=', '10022');
// or
// show duplicate buttons on rows that DON'T meet the condition 
// 'postalCode = 10022'
$xcrud->duplicate_button(false, 'postalCode', '=', '10022'); 

# emails_label()

Creates label for links in grid view.

Parameter Type Default Description
$text string '' Email address get replaced with $text in list view.
$xcrud->emails_label('Contact email');

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

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

Parameter Type Default Description
$xcrud->field_tooltip('productName','Enter product name here');

# 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).

Parameter Type Default Description
$xcrud->hide_button('save_return');

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

# highlight()

Adds background color or class attribute in list view for a grid cell based on set condition.

Parameter Type Default Description
$columns string '' Field name to compare with $value.
$operator string '' Comparison operator.
$value string '' Value to compare to $columns.
$color string '' Background color name or hexadecimal color value.
$class string '' CSS classname(s) separated by space characters.
// background color where orderNumber = '10101'
$xcrud->highlight('orderNumber','=','10101','red');
$xcrud->highlight('orderNumber','>=','10113','#87FF6C');

// Assign CSS class main-city
$xcrud->highlight('city','=','Madrid','','main-city'); 

# highlight() {column} tags usage:

A column tag is a table fieldname (column) enclosed by curly braces i.e. '{fieldname}'. Use these to compare $columns to another field from current row.

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

# highlight_row()

The same as highlight(), but the full row will be highlighted in the specified $color.

// background color where orderNumber = '10101'
$xcrud->highlight_row('orderNumber','=','10101','red');
$xcrud->highlight_row('orderNumber','>=','10113','#87FF6C');

// Assign CSS class main-city
$xcrud->highlight_row('city','=','Madrid','','main-city'); 

# label()

Set field name aliases.

Parameter Type Default Description
$fields mixed '' Table field name or an associative array of field => alias pairs.
$label string '' Field name alias only if $fields is a string.
$xcrud->label('name','Your Name'); // name AS 'Your Name'
// or
$xcrud->label(array('name' => 'Your Name')); // name AS 'Your Name'

# limit()

Set the number of rows to display per page in list view.

Parameter Type Default Description
$limit int 20 Rows to display per page in list view.
$xcrud->limit(25);

# limit_list()

Set pagination limit options to be shown on the pagination bar at the bottom of the list screen.

Parameter Type Default Description
$limit_list mixed '' Comma separated string or an array of strings.
Also accepts the option 'all'; displays the entire result set.
$xcrud->limit_list('5, 10, 15, all');
// or
$xcrud->limit_list(array('5', '10', '15', 'all'));

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

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

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

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

# order_by()

ORDER BY clause. Applies for only one field and it's sort order. Multiple calls can be made for each field in the ORDER BY clause.

Parameter Type Default Description
$fields string '' Field name or an associative array of field => direction pairs..
$direction string 'asc' Sorting order only if $fields is a string.
Accepted values: 'asc' or 'desc'
$xcrud->order_by('name'); // ORDER BY name ASC
$xcrud->order_by('city','desc');  // ORDER BY name ASC, city DESC
// or
$xcrud->order_by(array('name', 'city' => 'desc')); // ORDER BY name ASC, city DESC

# remove_confirm()

Removes confirmation window on remove action.

Parameter Type Default Description
$bool bool true Set true and you shall be prompted to confirm delete actions. Set to false the confirmation prompt on delete is hidden.
$xcrud->remove_confirm(false);
$xcrud->remove_confirm();  // undo action above

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

Defines column list for search and default search column

Parameter Type Default Description
$xcrud->search_columns('productVendor,quantityInStock,buyPrice','quantityInStock');

# send_email_public()

Send email with xCRUD.

Parameter Type Default Description
$to string Recipient email address.
$subject string Email subject.
$message string Email message body.
$cc array() Carbon copy (cc) email to specified in string array of email addresses.
$html boolean Default email message type is HTML. Setting to false sends the email body as plain text.

Configure the following parameters in xcrud_config.php. You can get these from your email provider.

// SMPT Mail configuration in file xcrud_config.php

//Set the hostname of the mail server   
public static $mail_host = 'mail.email.com'; 
//Set the SPMT port number - likely to be 25, 465 or 587
public static $mail_port = 587; 
//Whether to use SMTP authentication
public static $smtp_auth = true; 
//Username to use for SMTP authentication
public static $username = 'xcrud17@email.com'; 
//Password to use for SMTP authentication
public static $pass = 'sTr0ng^pa55word=='; 
//Set who the message is to be sent from
public static $emailfrom = 'xCRUD Company'; 
//Sets connection prefix. Options are - "", "ssl" or "tls"
public static $smtpsecure = 'tls';

Example

$xcrud = Xcrud::get_instance();

$emailBody = "Hey there. xCRUD sends email!!";
$subject = "Email Test";

$to = "xcrud@mailinator.com";
$xcrud->send_email_public($to, $subject, $emailBody, $cc = array(), true);

echo "<br>Click <a href='https://www.mailinator.com/v4/public/inboxes.jsp?to=xcrud'>here </a>to access the email that has just been sent! <br>";
    

# show_primary_ai_column()

Display the PRIMARY AUTO_INCREMENT field in list view.

Parameter Type Default Description
$bool boolean true Display the PRIMARY AUTO_INCREMENT field if set to true and otherwise for false.
$xcrud->show_primary_ai_column(); 

# start_minimized()

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

Parameter Type Default Description
$bool bool true Set true to render the xCRUD instance as hidden. The .xcrud-container is set to display: none;. Set to false displays the xCRUD instance, if already hidden.
$xcrud->start_minimized();
$xcrud->start_minimized(false); // undo action above

# subselect()

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

Parameter Type Default Description
$column_name string '' The name of the field.
$sql string '' SQL query to obtain the field data. You can use {column} tags in the query.
$before mixed false If specified, the field will be shown before this field else, it's placed as the last field.
//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->label(array('Order total' => 'Order Amount'));
$xcrud->column_class('Order total', 'align-right'); 
$xcrud->change_type('Order total','price','',array('prefix'=>'$'));
$xcrud->order_by('Products count');

# subselect() {column} tags usage:

A column tag is a table fieldname (column) enclosed by curly braces i.e. '{fieldname}'. You can use {column} tags in the $sql query to reference the main table's current row fields.

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

# sum()

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.

Parameter Type Default Description
$fields mixed '' String array or a comma separated list of field(s) to calculate sums for.
$class string '' CSS classname.
$custom_text string '' Custom text pattern. e.g. 'Total price is {value}'); {value} tag being the sum.
$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

# table_name()

Set table title.

Parameter Type Default Description
$name mixed '' Table title.
$tooltip mixed false Icon tooltip (on mouse hoover over the icon).
$icon mixed false Predefined classname. See default theme icons here: xcrud/themes/default/fonts.css (opens new window)
$xcrud->table_name('My custom table!');
$xcrud->table_name('My custom table!', 'Some tooltip text','icon-leaf');

// no icon specified. a ? is displayed to enable 
// viewing the tooltip on icon hover
$xcrud->table_name('My custom table!', 'Some tooltip text'); 

# unset_add()

Hides create (add) button from list view.

Parameter Type Default Description
$bool boolean true Set true to hide the create (add) button, false to show it, if already hidden.
$xcrud->unset_add(); // hide create (add) button
$xcrud->unset_add(false);  // undo action above

# unset_csv()

Hides the Export into CSV button from the list view.

Parameter Type Default Description
$bool bool true Set true to hide the export into csv button, false to show it, if already hidden.
$xcrud->unset_csv();
$xcrud->unset_csv(false); // undo action above

# unset_edit()

Hide edit buttons for all rows in list view. It can also hide the edit buttons given a condition.

Parameter Type Default Description
$bool bool true Set true to hide the edit buttons, false to show it, if already hidden.
If the other parameters below are provided, set true to hide the edit buttons for rows that meet the condition. Set false to hide the edit buttons for rows that DON'T meet the condition.
$field mixed false Conditional table field to compare with $value.
$operand mixed false Comparison operator to use on $field and $value.
$value mixed false Value to compare with $field.
$xcrud->unset_edit(); // hide all edit buttons for each row
$xcrud->unset_edit(false); // undo action above

// hide edit buttons on rows that meet the condition 
// 'postalCode = 10022'
$xcrud->unset_edit(true, 'postalCode', '=', '10022');
// or
// hide edit buttons on rows that DON'T meet the condition 
// 'postalCode = 10022'
$xcrud->unset_edit(false, 'postalCode', '=', '10022'); 

# unset_limitlist()

Hides the list view limits buttons or dropdown.

Parameter Type Default Description
$bool bool true Set true to hide the list view limits buttons or dropdown, false to show them, if already hidden.
$xcrud->unset_limitlist();
$xcrud->unset_limitlist(false); // undo action above

# unset_list()

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

Parameter Type Default Description
$bool bool true Set true to turn off grid view, false to turn on grid view, if already hidden.
$xcrud->unset_list();
$xcrud->unset_list(false); // undo action above

# unset_numbers()

Hide the row numbering column in list view.

Parameter Type Default Description
$bool bool true Set true to hide the row numbering column, false to show it, if already hidden.
$xcrud->unset_numbers();
$xcrud->unset_numbers(false); // undo action above

# unset_pagination()

Hides the pagination buttons.

Parameter Type Default Description
$bool bool true Set true to hide the pagination buttons, false to show them, if already hidden.
$xcrud->unset_pagination();
$xcrud->unset_pagination(false); // undo action above

# unset_print()

Hides the print button.

Parameter Type Default Description
$bool bool true Set true to hide the print button, false to show it, if already hidden.
$xcrud->unset_print();
$xcrud->unset_print(false); // undo action above

# unset_remove()

Same as unset_edit() but hides delete buttons for all rows in list view. It can also hide the delete buttons given a condition.

$xcrud->unset_remove(); // hide all delete buttons for each row
$xcrud->unset_remove(false); // undo action above

// hide delete buttons on rows that meet the condition 
// 'postalCode = 10022'
$xcrud->unset_remove(true, 'postalCode', '=', '10022');
// or
// hide delete buttons on rows that DON'T meet the condition 
// 'postalCode = 10022'
$xcrud->unset_remove(false, 'postalCode', '=', '10022'); 

Hides the search feature.

Parameter Type Default Description
$bool bool true Set true to hide the search functionality, false to show it, if already hidden.
$xcrud->unset_search();
$xcrud->unset_search(false); // undo action above

# unset_sortable()

Makes columns unsortable.

Parameter Type Default Description
$bool bool true Set true to makes columns unsortable, false to enable column sorting, if already hidden.
$xcrud->unset_sortable();
$xcrud->unset_sortable(false); // undo action above

# unset_title()

Hides the table title.

Parameter Type Default Description
$bool bool true Set true to hide the table title, false to show it, if already hidden.
$xcrud->unset_title();
$xcrud->unset_title(false); // undo action above

# unset_view()

Same as unset_edit() but hides view buttons for all rows in list view. It can also hide the view buttons given a condition.

$xcrud->unset_view(); // hide all view buttons for each row
$xcrud->unset_view(false); // undo action above

// hide view buttons on rows that meet the condition 
// 'postalCode = 10022'
$xcrud->unset_view(true, 'postalCode', '=', '10022');
// or
// hide view buttons on rows that DON'T meet the condition 
// 'postalCode = 10022'
$xcrud->unset_view(false, 'postalCode', '=', '10022'); 
Last Updated: 11/1/2021, 10:10:17 PM