# Class: Grid

## Grid

Grid

## Constructor

#### new Grid(selector, template, optionsopt)

Creates a new grid instance.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`selector` | String |  | jQuery selector.
`template` | String |  | The template selector.
`options` | Object | <optional> | The options object to apply to the grid.

Source:
  - Grid.js, line 16

### Methods

- (static) count() → {Number}
- (static) db(dbopt) → {*}
- (static) drop() → {boolean}
- (static) from(dataSource) → {Grid}
- (static) insert()
- (static) name(valopt) → {Grid}
- (static) refresh()
- (static) remove()
- (static) state(valopt) → {Grid}
- (static) template(template) → {*}
- (static) update()
- (static) updateById()
- query(queryObj, queryOptions) → {Grid}

#### (static) count() → {Number}

Returns the number of documents currently in the grid.

Source:
  - Grid.js, line 551

##### Returns:

Type
  Number

#### (static) db(dbopt) → {*}

Gets / sets the db instance this class instance belongs to.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`db` | Db | <optional> | The db instance.

Source:
  - Grid.js, line 151

##### Returns:

Type
  *

#### (static) drop() → {boolean}

Drops a grid and all it's stored data from the database.

Source:
  - Grid.js, line 174

##### Returns:

True on success, false on failure.

Type
  boolean

#### (static) from(dataSource) → {Grid}

Sets the data source from which the grid will assemble its data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataSource` | View | The data source to use to assemble grid data.

Source:
  - Grid.js, line 114

##### Returns:

Type
  Grid

#### (static) insert()

Executes an insert against the grid's underlying data-source.

Source:
  - Grid.js, line 78

#### (static) name(valopt) → {Grid}

Gets / sets the current name.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`val` | String | <optional> | The name to set.

Source:
  - Grid.js, line 69

##### Returns:

Type
  Grid

#### (static) refresh()

Refreshes the grid data such as ordering etc.

Source:
  - Grid.js, line 276

#### (static) remove()

Executes a remove against the grid's underlying data-source.

Source:
  - Grid.js, line 105

#### (static) state(valopt) → {Grid}

Gets / sets the current state.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`val` | String | <optional> | The name of the state to set.

Source:
  - Grid.js, line 60

##### Returns:

Type
  Grid

#### (static) template(template) → {*}

Gets / sets the grid's HTML template to use when rendering.

##### Parameters:

Name | Type | Description
--- | --- | ---
`template` | String | The template's jQuery selector.

Source:
  - Grid.js, line 219

##### Returns:

Type
  *

#### (static) update()

Executes an update against the grid's underlying data-source.

Source:
  - Grid.js, line 87

#### (static) updateById()

Executes an updateById against the grid's underlying data-source.

Source:
  - Grid.js, line 96

#### query(queryObj, queryOptions) → {Grid}

Sets the base query and query options on the grid that will remain part of the query regardless of other changes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`queryObj` | Object | The query object.
`queryOptions` | Object | The query options object.

Source:
  - Grid.js, line 269

##### Returns:

Type
  Grid