new DataView(datacolumns, datarows)
Parameters:
| Name | Type | Description |
|---|---|---|
datacolumns |
Array.<pear.data.Column> | Array of pear.data.Column |
datarows |
Array.<Object.<string, *>> |
- Source:
Example
var columns = [
new pear.data.Column("Order No",'orderno','orderno',75,
pear.data.Column.DataType.NUMBER),
new pear.data.Column("Item",'item','item',115,
pear.data.Column.DataType.TEXT),
new pear.data.Column("Unit Price",'unitprice','unitprice',
75,pear.data.Column.DataType.NUMBER),
...
...
];
// that datarow object property name is identical to the Column Id
var data = [
{orderno:1,item:'Samsung-Galaxy',unitprice:200,...,...,...},
{orderno:2,item:'Iphone',unitprice:200,...,...,...},
{orderno:3,item:'Kindle-Fire',unitprice:200,...,...,...},
...
...
...
];
// Create DataView Object
var dataView = new pear.data.DataView(columns,data);
Extends
- goog.events.EventTarget
Members
-
<static> EventType :string
-
DataView Events
Type:
- string
- Source:
Properties:
Name Type Default Description DATAVIEW_CHANGEDString dataview-changed When DataView is changed - like row added ,removed or updated DATASOURCE_CHANGEDString datasource-changed When DataView is initialized - this is primarily when DataRows are changed ROWVIEW_CHANGEDString rowview-changed This event is fired for each Row Added/Updated/Removed Note : not yet implemented ROWVIEW_SELECTString rowview-select This event is fired when a rowview is added to "rowview select" collection ROWVIEW_UNSELECTString rowview-unselect This event is fired when a rowview is removed from "rowview select" collection DATAROW_CHANGEDString datarow-changed This event is fired for each Row Added/Updated/Removed -
<static> FilterType :number
-
Type:
- number
- Source:
Properties:
Name Type Default Description LIKEnumber 1 EQUALnumber 2 GREATER_THANnumber 3 LESS_THANnumber 4 BETWEENnumber 5
Methods
-
addColumnFilter(dataColumn, filter)
-
Add a filter expression for a datacolumn , currently grid support one filter expression per column
Parameters:
Name Type Description dataColumnpear.data.Column filterstring - Source:
-
addDataRow(datarow)
-
Add a DataRow
Parameters:
Name Type Description datarowObject.<string, *> - Source:
-
applyFilter(fnFilter, op_context) → {Array.<pear.data.RowView>}
-
Apply filter on DataView , it uses http://goo.gl/USG5xs
Parameters:
Name Type Description fnFilterfunction op_contextObject - Source:
Returns:
- Type
- Array.<pear.data.RowView>
Example
var filteredRows = dv.applyFilter(filterfn,this); dv.setDataRowViews(filteredRows); ... ... var filterfn = function(rowview) { var columns = dv.getDataColumns(); var match = true; goog.array.forEach(columns,function(column){ var rowdata= rowview.getRowData(); if (column.filter && column.filter.length > 0){ var str; var filter = String(column.filter); if (column.formatter){ str = String(column.formatter(rowdata[column.id])); }else{ str = String(rowdata[column.id]); } if (str.toLowerCase().indexOf(filter.toLowerCase()) >=0) { match = match && true; }else{ match = match && false; } }else{ } },this); return match; }; -
clearColumnFilter(dataColumn)
-
remove filter expression from the column
Parameters:
Name Type Description dataColumnpear.data.Column - Source:
-
clearSelectedRowViews()
-
Clear the Selected RowView collection
- Source:
-
<protected> disposeInternal()
-
- Source:
-
getColumnFilter(dataColumn) → {string}
-
get fitler expression for the column
Parameters:
Name Type Description dataColumnpear.data.Column - Source:
Returns:
- Type
- string
-
getColumns() → {Array.<pear.data.Column>}
-
get All Columns info
- Source:
Returns:
- Type
- Array.<pear.data.Column>
-
getDataRowById(rowid) → {Object.<string, *>}
-
Get DataRow by RowView Id i.e RowId
Parameters:
Name Type Description rowidstring - Source:
Returns:
- Type
- Object.<string, *>
-
getDataRows() → {Array.<Object.<string, *>>}
-
Get DataRows
- Source:
Returns:
- Type
- Array.<Object.<string, *>>
-
getDataRowViewCount() → {number}
-
Get DataRowView count this could be different than DataRow Count e.g if you set Filter on Grid , DataRowView count will return all the rows which are result of filter being applied where as , getDataRowCount will return all rows available
- Source:
Returns:
- Type
- number
-
getDataRowViews() → {Array.<pear.data.RowView>}
-
get DataRow View
- Source:
Returns:
- Type
- Array.<pear.data.RowView>
-
getGrid() → {pear.ui.Grid}
-
Return the instance of Grid on which DataView is used There can be one Grid per instance of DataView
- Source:
Returns:
- Type
- pear.ui.Grid
-
getRowCount() → {number}
-
Get the row count of Actual datasource (DataRows in DataTable)
- Source:
Returns:
- Type
- number
-
getSelectedRowViewsIds() → {?Array.<string>}
-
Get Id's of Selected RowViews
- Source:
Returns:
- Type
- ?Array.<string>
-
isDatasourceChanged() → {boolean}
-
- Source:
Returns:
- Type
- boolean
-
removeDataRow(id)
-
Remove a DataRow
Parameters:
Name Type Argument Description idstring <nullable>
- Source:
-
resetDatasourceChangeIndicator()
-
- Source:
-
selectRowView(rowview, select)
-
Select a RowView , this method will fire ROWVIEW_SELECT and ROWVIEW_UNSELECT event
Parameters:
Name Type Description rowviewpear.data.RowView selectboolean - Source:
Fires:
- pear.data.DataView.EventType#event:ROWVIEW_SELECT
- pear.data.DataView.EventType#event:ROWVIEW_UNSELECT
-
setColumns(dc)
-
set column info of dataview
Parameters:
Name Type Description dcArray.<pear.data.Column> - Source:
-
setDataRows(data)
-
Set DataRows , this will fire DataSourceChange and DataViewChange event
Parameters:
Name Type Description dataArray.<Object.<string, *>> - Source:
Fires:
- pear.data.DataView.EventType#event:DATASOURCE_CHANGED
- pear.data.DataView.EventType#event:DATAVIEW_CHANGED
Example
var data = [ {orderno:1,item:'Samsung-Galaxy',unitprice:200,...,...,...}, {orderno:2,item:'Iphone',unitprice:200,...,...,...}, {orderno:3,item:'Kindle-Fire',unitprice:200,...,...,...}, ... ... ... ]; // Set DataRows myDataView.setDataRows(data); -
setDataRowViews(rowViews)
-
Set DataView
Parameters:
Name Type Description rowViewsArray.<pear.data.RowView> - Source:
-
setGrid(grid)
-
this should not be used to set a Grid , this is used internally by grid to set itself when DataView is assigned to Grid
Parameters:
Name Type Description gridpear.ui.Grid - Source:
- See:
-
sort(sortDirection, columnid)
-
Basic Sort
Parameters:
Name Type Description sortDirectionpear.ui.Grid.SortDirection SortDirection columnidstring pear.data.Column.id - Source:
-
updateDataRow(uniqueid, datarow)
-
Update a DataRow
Parameters:
Name Type Description uniqueidstring datarowObject.<string, *> - Source: