awa.ui.CollectionGrid Class
/var/www/azaleahealth.com/branches/docs/source_repo/awa/resources/apps/js/awa/ui/CollectionGrid.js:116
View for tabular data. Avoid accessing properties of the grid directly. Instead, use the provided methods or add methods as you see fit. Try and make use of the columns option or attributeProps in the model of the collection. The grid will pull the name and the display method from the model if you give the id.
Events: "rowclick" - Fires when a user clicks on a grid row. Params: The data for that row. "rowdblclick" - Fires when a user double clicks on a grid row. Params: The data for that row. "page" - Fires when a user changes the grid page. Params: The new page number. "rendered" - Fires when the grid is finished rendering "action" - Fires when a user defined action is triggered
To listen for an event, just do the following with your grid object: grid.bind("rowclick", myobj.onRowClick, myobj)
The Grid also exposes an Autocomplete object: grid.autocomplete
// bare minimum
new awa.ui.CollectionGrid({
collection: new awa.mvc.Collection([], {model: ExampleModel}),
columns: [
{id: "exa_id"},
{id: "exa_string"},
{id: "exa_text"},
{id: "exa_ssn"}
]
});
Constructor
awa.ui.CollectionGrid
-
options
Parameters:
-
optionsObject-
collectionCollectionRequired Collection for the grid to use. Be careful with using shared collections as this view will try and control the collection on occasion.
-
[columns]awa.ui.CollectionGrid.Column optionalan array of objects that outline the columns for the grid.
-
[itemsPerPage]Integer optional -
[page]Integer optional -
[prefetch]Boolean optional -
[rowclick]Function optionalpassed the model that represents data for the row
-
[syncOnRowSubmit]Boolean optionaldefaults to true
-
[panels]? optional -
[title_bar]Boolean optional -
[footer_bar]Boolean optional -
[table_header]Boolean optional -
[items_per_page_input]Integer optional -
[customRowClassNewArgs]Boolean optionalcustomRowClass function now receives an args object with the json property and a model property
-
[customRowClass]Function optional -
[onCollectionInconsistency]Function optionalallows you to catch errors such as duplicate rows
-
[scope]String optionalScoping for model forms
-
[multiselect]Boolean optionalFor checkmark greatness simple multiselect grid with no controls within grid to save choices
-
[persistent_multiselect]Boolean optional(defaults false) multiselect grid which shows dynamically growing or shrinking list at bottom with controls to save multiple choices to a previously defined collection, i.e. icd9s or cpts
-
[bookmark]Boolean optionalFor bookmark greatness. Use at your own risk.
-
[noResultsDisplay]String optional -
[hideOnEmpty]Boolean optionalHides when no results are found. CAUTION, will show element automatically when results are found.
-
[showTotalRowCountOption]Boolean optionalDefaults to true, allows user to include total row count
-
[searchable]Boolean optionalAllows for grid searching. Use instead of Autoselect
-
[autoFocus]Boolean optionalIf options.searchable and this is enabled, the search box will receive focus on render
-
[initialRowFocus]Boolean optionalSets the row to focus on initialization; Negative value for none
-
Item Index
Methods
- buildMultiSelectDynamicList
- checkByModelID
- checkByRowIDs
- customRowClassModelFunction
- generateDisableButtonConfig
- generateEditButtonConfig
- generateEnableButtonConfig
- getFieldByID
- getFieldByRow
- getRowElement
- getSelected
- getSelectedIds
- getSelectedModels
- hideColumn
- initRowEdit
- isColumnVisible
- resetPersistentSelectedCollection
- showColumn
- showPage
Methods
buildMultiSelectDynamicList
()
Undefined
build the Persisted multiselect list. Internal use only
Returns:
checkByModelID
-
ids -
options
Parameters:
-
idsArrayArray model ids to check
-
optionsObjectObject parameter bag
Returns:
Array of currently selected models models
checkByRowIDs
-
ids -
options
Parameters:
-
idsArrayArray row ids to check
-
optionsObjectObject parameter bag
Returns:
Array of currently selected models models
customRowClassModelFunction
-
args
generic custom row class to be used with collection grids
Parameters:
-
argsObjectArguments passed on call
-
modelawa.mvc.ModelConfiguration
-
Returns:
css class for the grid row
generateDisableButtonConfig
-
config
Parameters:
-
configObjectConfiguration
Returns:
Configuration for default disable button
generateEditButtonConfig
-
config
Parameters:
-
configObjectConfiguration
-
ModelClassConstructorconstructor for model
-
Returns:
Configuration for default edit button
generateEnableButtonConfig
-
config
Parameters:
-
configObjectConfiguration
Returns:
Configuration for default enable button
getFieldByID
-
id -
col_id
Parameters:
-
idString | IntegerModel id
-
col_idString | Integerattribute key on column
Returns:
field
getFieldByRow
-
row_id -
col_id
Parameters:
-
row_idString | IntegerRow id
-
col_idString | Integerattribute key on column
Returns:
field
getRowElement
-
id
Parameters:
-
idString | Integerid of Model
Returns:
row
getSelected
()
Array
Returns:
Array of currently selected models models
getSelectedIds
()
Array
Returns:
Array of Model ids
getSelectedModels
()
Array
Returns:
Array of models
hideColumn
-
colID
Hides a field for all rows in the grid
Parameters:
-
colIDStringColumn id attribute
Returns:
initRowEdit
-
args
Starts singular row edit on grid
Parameters:
-
argsObjectOptions
-
row_idString | IntegerRow id to start edit mode
-
Returns:
isColumnVisible
-
colID
Parameters:
-
colIDStringColumn id attribute
Returns:
Indicates if column is visible
resetPersistentSelectedCollection
()
Undefined
Clears currently selected items
Returns:
showColumn
-
colID
Shows a field for all rows in the grid
Parameters:
-
colIDStringColumn id attribute
Returns:
showPage
-
page -
[callback] -
[fetch]
Have the grid display the page requested.
Parameters:
-
pageIntegerThe page number to be displayed.
-
[callback]Function optionalcallback Function to be called when rendering of the page is complete
-
[fetch]Boolean optionalIndicates if collection should fetch or use existing data
Returns:
this