# Sigma.Grid

- Index
- Sigma
- Sigma.Grid
- Sigma.Column
- Sigma.Column.Editor
- Sigma.DataSet
- Sigma.DataSet.field
- Sigma.Grid.PageInfo
- Sigma.Grid.SortInfo
- Sigma.Grid.FilterInfo
- Sigma.Grid.Event
- Sigma.Grid.EventTarget
- DataExchange

## Instance Properties

activeCell
DOM. Dom object of current active cell. Read only.
activeRecord
Object or Array. Data set of current active row. Read only.
clickStartEdit
Bool. To specify whether cell becomes editable once it is clicked. If this flag set to false, user need to click once more to edit an active cell.
columnList
Array. Array of all the column objects. Read only.
columnMap
Object. Object of column objects in in key-value formate, where key is column id and value is column object. Read only.
container
Sting or DOM.
Id or dom object which grid is built up based on. Generally, container should be div or span. Sample
<div id="gridcontainer"> </div>
container:gridcontainer
customHead
String or DOM.
Id, dom object or HTML code of a table, which defines layout of grid header.
Sample1 - to guade to build a grid header with submit button
<table id="gridHead1">
<tr><td>Column1</td><td>Column2</td></tr>
<tr><td><input type="button" value="submit"></td><td>Column2</td></tr>
</table>
customHead:gridHead1
Sample2 - to guade to build a nested header
<table id="gridHead1">
<tr><td>Column1</td><td colspan="2">Column2</td></tr>
<tr><td>Column1 Sub</td><td>Column2 Sub1</td><td>Column2 Sub2</td></tr>
</table>
customHead:gridHead1
dataset
Object. Dataset object of grid. Read only. See Sigma.Dataset
debug
Bool. To specify grid to be in debug mode. To be in debug mode can call out a console with more info printed.
defaultRecord
Object or Array.
Data record template. This template will be adopted if a new row is added or appended.
Sample - When a row is added, it is initialized with "somebody", 0, 25 in column1, comlumn2, and comlumn3 respectively.
defaultRecord:["somebody", 0, 25]
If data type is object, it should be
defaultRecord:{name:"somebody", field:0, moreField:25]
groupable
Bool. To specify whether grouping menu is enabled. If this flag is set true, grouping menu will appears in main menu and grouping functionality is enabled.
height
Integer or String.
Height of whole grid. Pixel and percentage are supported. Sample
height:200
width:100%
id
String. Id of grid. Every grid should have unique id if more than one grid appear on same page.
Sample
id : "sigmagrid1"
jsonParamName
String. To specify parameter name submitted to server side. It's set to "_gt_json" by default. For example, PHP developer could get whole JSON string by $_POST["_gt_json"] in php.
language
String. Language option.
By default, messages on toolbar, on menu, of warning are in english. These words for presentation are defined in a language file named gt_msg_en.js. Developer can work out profile of other language. Take Spaish for example, developer need two steps.
1. Work out language file named gt_msg_sp.js and put into the directory where gt_msg_en.js is.
2. Specify language of grid to be sp.
Sample
language:"sp"
lightOverRow
Bool. To specify whether to hightlight one row when mouse is hovering over it.
loadUrl
String. Url which grid data is loaded from. A function could also be assigned to loadUrl.
Sample1 - To assign a real url to loadUrl.
loadUrl:"http://localhost/server/getStudentsInfo.php'
Sample2 - To assign a call back function to loadUrl.
function getTestData(grid) {
var responseT={};
var pageInfo= grid.getPageInfo();
responseT[grid.CONST.data]=__TEST_DATA__.slice( pageInfo.startRowNum-1,pageInfo.endRowNum);
responseT[grid.CONST.pageInfo]={totalRowNum :__TEST_DATA__.length } ;
return responseT;
}
loadUrl:getTestData
minHeight
Integer. To specify minimum height if grid can be resized by end user.
minWidth
Integer. To specify minimum width if grid can be resized by end user.
pageInfo
Object Page info of grid. See Sigma.Grid.PageInfo
reloadAfterSave
Bool. To specify whether grid data is reloaded after data being saving.
remoteFilter
Bool. To specify whether server side does filtering work.
remotePaging
Bool. To specify whether server side does paging work.
remoteSort
Bool. To specify whether server side does sorting work.
replaceContainer
Bool.
To specify whether container is placed with grid. If not, grid will be a child of container. Sample
replaceContainer:false
resizable
Bool. To specify grid be resized by end user. If this flage to be set true, a resizing handle will appears at right-bottom corner. End user could resize grid by dragging this handle.
saveUrl
String. Url which grid data is saved to.
Sample
saveUrl:"http://localhost/server/saveStudentsInfo.php'
selectedRows
Array. Array of selected row objects. Read only.
showAddTool
Bool. To specify whether "Add" button shows up.
showChartTool
Bool. To specify whether "Chart" button shows up.
showDelTool
Bool. To specify whether "Delete" button shows up.
showFilterTool
Bool. To specify whether "Filter" button shows up.
showGridMenu
Bool. To specify whether main menu shows up.
showIndexColumn
Bool. To specify whether to show row number at front of every row.
showReloadTool
Bool. To specify whether "Reload" button shows up.
showSaveTool
Bool. To specify whether "Save" button shows up.
stripeRows
Bool. To specify whether to show rows in stripe.
width
Integer or String.
Width of whole grid. Pixel and percentage are supported. Sample
width:500
width:100%

## Instance Methods

addParameters:function(parameters)
To add an additional parameter pair for submittal. By default, only data defined here will be submitted to server side. By this function, developers could add more parameter pairs.
parameters: Addtional parameters in key-value formate.
Sample
addParameters({morekey1:"more value",morekey2:"more value"})
cleanParameters:function()
Remove all additional parameters. See Sigma.Grid.addParameters
closeMainMenu:function()
To Close main menu.
filterGrid:function()
Apply filter to this grid. Developer need to specify filterInfo before calling this function. Only records meeting filter criteria will be displayed within grid.
getColumn:function(colNoIdTd)
Get column object by column id or DOM object of cell.
colNoIdTd: Column id or DOM object of cell.
returns: Column object.
getColumnValue:function(colID,rowNo)
Set cell value by specifying column id and row number.
colID: string. Id of column where cell is in.
rowNo: integer. Number of row where cell is at.
returns: any. New cell value.
Sample
var ret = grid.getColumnValue("col1",1);
getDeletedRecords:function()
To get all records deleted.
returns: Array of records.
getEventTargets(event)
To get event target.
event: Sigma.Grid.Event object. See Sigma.Grid.Event
returns: Sigma.Grid.EventTarget object. Sigma.Grid.EventTarget#
getInsertedRecords:function()
To get all records deleted.
returns: Array of records.
getRecord:function( rowNoTdTr)
Get record by row number or DOM of td or tr.
rowNoTdTr: Row number or DOM of td or tr.
returns: Record object.
getUpdatedRecords:function()
To get all records updated.
returns: Array of records.
hideCellToolTip:function()
To hide tool tip for cell.
hideDialog:function ()
To hide dialog.
hideMask:function()
To hide mask.
hideWaiting:function ()
To hide waiting bar.
onShow:function()
To show grid. This function must be called when a hidden grid becomes visible.
refresh:function()
To rebuild grid without data reloaded.
reload:function(data)
To reload data and rebuild grid.
removeParameter:function(key)
Remove additional parameters by key.
Sample
removeParameter("morekey1")
setColumnValue:function(colID,rowNo,newValue)
Set cell value by specifying column id and row number.
colID: string. Id of column where cell is in.
rowNo: integer. Number of row where cell is at.
newValue: any. New cell value.
Sample
grid.setColumnValue("col1",1,"value11");
setSize:function(newWidth,newHeight)
To set grid width and height.
newWidth: New width.
newHeight: New height.
showCellToolTip(cell,width)
To show tool tip for cell.
cell: DOM of cell.
width: Width of tip bar.
showDialog:function (type)
To show a dialog.
type: Dialog type.
showMask:function()
To show a mask.
showWaiting:function ()
To show a waiting bar.
toolbarContext
String. It's set to 'nav | pagesize | reload | add del save | print | filter chart | info' by default.
Developer can change its order.
unfilterGrid:function()
To release grid from filter. See Sigma.Grid.filterGrid also.

## Static Methods

findGridByElement:function(obj)
To find grid by td or tr object.
obj: DOM object of td or tr.
getAllrows:function(grid)
Get array of html element tr dom within one grid.
grid: Object. Grid object.
returns: Array of html element tr dom.
isSelectedRow:function(row)
To determine whether one row is selected.
row: DOM. HTML tr dom object.
returns: Bool. True for selected, false for not.
render:function(grid)
To render a grid.
grid: Grid object.

## Events

afterEdit:function()
Fired before: Cell is out of editable mode.
Developer can get active cell by refering to activeCell. See Sigma.Grid.activeCell
Developer can get active record by refering to activeRecord. See Sigma.Grid.activeRecord
beforeDelete:function(record)
Fired before: A row is to be deleted.
record: Object or Array. Record of the row to be deleted.
returns: Bool. Return false to prevent row from being deleted.
beforeEdit:function()
Fired before: Cell comes into editable mode.
Developer can get active cell by refering to activeCell. See Sigma.Grid.activeCell
Developer can get active record by refering to activeRecord. See Sigma.Grid.activeRecord
beforeInsert:function(record)
Fired before: Changed data is to be posted to server side.
record: Object or Array. Record of the row added/appended by end user.
returns: Bool. Return false to prevent row from being posted to server side.
beforeLoad:function(requestParameter)
Fired before: Grid is to about to load data from server side.
requestParameter: Object. See DataExchange.Loading
return: Bool. Return false to prevent grid from loading data from server side.
beforeSave:function(requestParameter)
Fired before: Changed data is to be posted to server side.
requestParameter: Object. See DataExchange.Saving
return: Bool. Return false to prevent data from being posted to server side.
beforeSelectRow:function(value, record , cell, row, colNO, rowNO, columnObj,grid)
Called before: End user selects one row.
value: Value of the cell where mouse pointer is at.
record: Object or array. Data record of the row to be selected.
cell: Dom of the cell where mouse pointer is at.
row: Dom of row to be selected.
colNo: Index of the column where mouse pointer is at.
columnObj: Column object.
grid: Grid object.
returns: Boolean. Return false to prevent row from being selected.
beforeUpdate:function(record,fieldName,newValue)
Fired before: Changed data is to be posted to server side.
record: Object or Array. Record of the row modified by end user.
fieldName: String. Id of column changed.
newValue: New value.
returns: Bool. Return false to prevent row from being posted to server side.
loadResponseHandler : function(response,requestParameter)
This function is a call back function to deal with the received content from server side. Developer could do some data translation work within this function.
response: String. Response content.
requestParameter: Object. See DataExchange.Loading
onClickCell:function(value, record , cell, row, colNO, rowNO,columnObj,grid)
Called before: End user click one cell.
value: Value of the cell where mouse pointer is at.
record: Object or array. Data record of the row where the cell is at.
cell: Dom of the cell.
row: Dom of row where the cell is at.
colNo: Index of the column where the cell is at.
columnObj: Column object.
grid: Grid object.
returns: Boolean. Return false to prevent cell from being active.
onComplete:function(grid)
Called when: Grid is completely loaded.
grid: Grid object.
onmouseout: function(event,grid)
Fired when mouse moves out of grid.
event: Object. See Sigma.Grid.Event
grid: Object. Grid Object.
onmouseover: function(event,grid)
Fired when mouse is hovering over grid.
event: Object. See Sigma.Grid.Event
grid: Object. Grid Object.
onResize:function()
Called when: Width or height of grid changes.
saveResponseHandler : function(response,requestParameter)
This function is a call back function to deal with the received content from server side. Developer could do some data translation work within this function.
response: String. Response content.
requestParameter: Object. See DataExchange.Saving