files()

Since: Editor 1.5

Get information about multiple uploaded files. Please note - this property requires the Editor extension for DataTables.

Description

This method is an alias of the files() method which accepts exactly the same parameters and returns the same results. This alias is provided on the DataTables API for convenience in cases where it is easier to use the DataTables API methods rather than Editor.

Please refer to the files() documentation for full details of this method.

Type

function files( [ table ] )

Description:

Get a list of files that have been previously uploaded via an Editor form (upload or uploadMany). The information available for each file is determined by how the db() method has been configured for the Upload class on the server-side (if this has been used). Please see the PHP and .NET for details on this method.

Parameters:
Returns:

If a table parameter is given, the object returned will contain an entry for each file that has been uploaded via the Editor upload fields. The object keys are the primary key values for the file's database entry.

If a table parameter is not given, an object is returned where the keys are the table names that have been defined for use on the server-side and the value an object as described above for individual tables.

Example

Use files() to log all files available from the database table documents (done in initComplete here):

$(document).ready(function() {
    var table = $('#example').DataTable( {
        dom: "Bfrtip",
        ajax: "../php/upload.php",
        columns: [
            { data: "users.first_name" },
            { data: "users.last_name" },
            { data: "users.phone" },
            { data: "sites.name" },
            {
                data: "users_files.fileId",
                render: function ( fileId ) {
                    return fileId ?
                        '<img src="'+table.file( 'files', fileId ).web_path+'"/>' :
                        'No image';
                }
            }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ],
        initComplete: function () {
            console.log( table.files( 'documents' ) );
        }
    } );
} );

Related

The following options are directly related and may also be useful in your application development.