Class Index | File Index

Classes


Class xataface.RecordBrowser


Defined in: RecordBrowser.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A dialog to select a record from a found set in a table.
Field Summary
Field Attributes Field Name and Description
 
The base url to the RecordBrowser directory.
 
Callback function to be called with the selected values.
 
el
The document element that is used to display the dialog.
 
Search filters to add to the query.
 
The name of the column to use as the title in the option list.
 
The name of the table to browse for records in.
 
The name of the column to use as the value in the option list.
Method Summary
Method Attributes Method Name and Description
<static>  
xataface.RecordBrowser.Callback(o)
A callback function that can registered as the callback for a RecordBrowser object to handle the case where a user has selected one or more records in a RecordBrowser dialog.
 
Displays the record browser dialog.
Class Detail
xataface.RecordBrowser(o)
A dialog to select a record from a found set in a table. This dialog is used in may parts of Xataface including the lookup and select widgets.

Screenshot of the RecordBrowser dialog as used inside the lookup widget:

Basic Example

//require <RecordBrowser/RecordBrowser.js> var RecordBrowser = XataJax.load('xataface.RecordBrowser'); // Now let's create a dialog to select records from the people table: var dlg = new RecordBrowser({ table: 'people', // A callback function to be called when the clicks "Select" callback: function(selected){ var selectedString = []; $(selected).each(function(id,title){ selectedString.push(id+' = '+title); }); selectedString = selectedString.join('\n'); alert("The following key/value pairs were selected: '+selectedString); } }); dlg.display(); // Display the dialog

Example with Filters

The following example only includes a list of people in Canada over the age of 18

var dlg = new RecordBrowser({ table: 'people', filters: { country: '=Canada', age: '>18' }, callback: function(selected){ // ... do stuff with selected values } }); dlg.display();
Parameters:
{Object} o
Initialization parameters.
{String} o.table
The name of the table from which to browse records.
{String} o.value
The name of the column to use as the value in the option list. If this is left null, then the primary key will be used as the value.
{String} o.text
The name of the column to use as the title in the option list. If this is left null, then the record's title (i.e. the result of $record->getTitle()) will be used.
{Object} o.filters
Optional key-value pairs to be used to filter the results. This is handy if you only want the dialog to show certain records from the table.
{xataface.RecordBrowser.Callback} o.callback
A callback function that will be called after the user clicks "select" to close the dialog. An object with the key/value pairs of selected records will be passed to this callback function.
Field Detail
baseURL
The base url to the RecordBrowser directory.

callback
Callback function to be called with the selected values. function(values){}

el
The document element that is used to display the dialog.

filters
Search filters to add to the query.

text
The name of the column to use as the title in the option list. Set this value to __title__ to use the record title ( or leave blank).

title
The name of the table to browse for records in.

value
The name of the column to use as the value in the option list. Set this value to __id__ to use the record id. If this value is blank, then the primary key is used so long as the primary key only has a single column. If it is a compound primary key, then the record id is used by default.
Method Detail
<static> {void} xataface.RecordBrowser.Callback(o)
A callback function that can registered as the callback for a RecordBrowser object to handle the case where a user has selected one or more records in a RecordBrowser dialog.
//require <RecordBrowser/RecordBrowser.js>
var RecordBrowser = XataJax.load('xataface.RecordBrowser');

// Now let's create a dialog to select records from the people table:
var dlg = new RecordBrowser({
    table: 'people',
	
    // A callback function to be called when the clicks "Select"
    callback: function(selected){
        var selectedString = [];
        $(selected).each(function(id,title){
            selectedString.push(id+' = '+title);
        });
        selectedString = selectedString.join('\n');
        alert("The following key/value pairs were selected: '+selectedString);
    }
});
dlg.display(); // Display the dialog
Parameters:
{Object} o
The key-value pairs of selected records. The keys are the "values" of the select list, and the values are the corresponding "texts" of the select list.
Returns:
{void}

{void} display()
Displays the record browser dialog.
Returns:
{void}

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 30 2012 15:10:18 GMT-0700 (PDT)