Class: PaferaChooser

PaferaChooser(config)

Control to display a screen where the user can choose items from a grid. Supports multiple selections, tree based navigation, and item reordering.

Constructor

new PaferaChooser(config)

Parameters:
Name Type Description
config object With so many options, please see the source to see what settings are available. The most commonly used ones are
div
A CSS selector given to the auto generated fullscreen layer.
reference
a global reference to this object such as G.listctrl. It is used for buttons and actions to refer to itself.
fields
An array containing the names of the fields that are shown in each card.
enablestacks, enablereorder, multipleselect
Set these to true to enable their various actions.
extrabuttons
HTML for extra buttons to show at the top toolbar.
customclickfunc
Enable to handle all of the click handling yourself instead of depending on the widget's default handling.
onfinished
Handler for when the user clicks on an item, or is done adding items in multiple select mode.
title
Text to use as the header.
Source:

Methods

AddSelected()

Adds every selected item to the chosen list.
Source:

Display()

Displays the widget inside the div specified at construction and setups all handlers.
Source:

DisplayAvailable()

Called by self.GetAvailable(), this displays the returned items from the server.
Source:

DisplayChosen()

Called by self.GetChosen(), this displays the items in self.chosen.
Source:

(async) GetAvailable(start)

Calls self.OnGetAvailable() with the desired position and search term. You should override OnGetAvailable() for custom handling instead of this function.
Parameters:
Name Type Description
start int The desired starting position, or leave undefined to use the last position.
Source:

GetChosen()

Gets the chosen items in self.chosen and displays them. Most of the time, you don't need to override this function since all it does is to display the items in self.chosen.
Source:

HasChildren(obj)

Override this method for selecting from tree structures. It should return true when obj has children objects.
Parameters:
Name Type Description
obj object Object to examine children for
Source:

Move(idcode, diff)

Called when reordering is enabled. This moves the chosen object with idcode to another position as specified by diff.
Parameters:
Name Type Description
idcode value ID of the item to be moved
diff int The difference between the current position and the new position
Source:

OnAvailableAdded(dbid, obj)

This handler is here for derived classes which want to perform additional actions when a chosen item is returned to the available pool.
Parameters:
Name Type Description
dbid value The database ID of the returned object
obj object The returned object
Source:

OnAvailableClicked(dbid)

Handles click events for available items, which normally results in calling self.onfinished(dbid, object) if the chooser is single selector or adding the item to self.chosen if the chooser is multiple select.
Parameters:
Name Type Description
dbid value Database ID of the clicked item
Source:

OnChosenAdded(dbid, obj)

This handler is here for derived classes which want to perform additional actions when a chosen item is added.
Parameters:
Name Type Description
dbid value The database ID of the added object
obj object The added object
Source:

OnChosenClicked(dbid)

Handles click events for chosen items, which normally just sends them back to self.available
Parameters:
Name Type Description
dbid value Database ID of the clicked item
Source:

(async) OnFinished()

Calls self.onfinished when the user clicks the finish button. The handler should have signature async func(dbid, chosenobject)
Source:

(async) OnGetAvailable(start, resultsdiv, searchterm)

Gets the available items and saves them in self.available to be displayed.
Parameters:
Name Type Description
start int The desired starting position
resultsdiv DOMElement The div to display the searching progress within
searchterm string An optional text string to search for
Source:

RemoveSelected()

Removes every selected chosen item and moves them back into the available pool.
Source:

RenderItem(r)

Renders the HTML of an item card. If not overridden, this will simply show all the fields in self.fields.
Parameters:
Name Type Description
r object The object to render
Source:

SelectAll()

Selects every currently displayed available item.
Source:

SelectNone()

Deselects every currently selected available item.
Source: