DbNetgrid Client Methods

Top  Previous  Next

addLinkedControl( control)

Adds a linked child DbNetGrid or DbNetEdit to the parent grid. Linked controls should have their properties assigned before being passed as an argument to the addLinkedControl method. There is no need to call the initialize method for linked controls as this is done automatically.
Parameters

control

object

Reference to the child grid or edit control.

Run Sample

addNestedGrid( handler)

Adds a nested child grid to the parent grid. The handler parameter specifies the function that will contain the nested grid configuration code and is passed a reference to the child grid for configuration.
Parameters

handler

function

Reference to the client-side function that will configure the nested grid

Run Sample

addToolbarButton( index)

Adds a button to the toolbar.

Returns

A reference to the button
Parameters

index

number

The position in the toolbar where you would like the button added. If no index is supplied the button is added at then end of the toolbar.

Run Sample

addToolbarElement( index, tagName)

Adds a button to the toolbar.

Returns

A reference to the button
Parameters

index

number

The position in the toolbar where you would like the button added. If no index is supplied the button is added at then end of the toolbar.

tagName

string

The tag name of the element to add e.g. "select"

Run Sample

bind(eventName, handler)

Binds a client-side function to an event
Parameters

eventName

string

Name of the event

handler

function

Reference to the client-side function

Run Sample

buildChart(chartConfig)

Builds a chart image based on the supplied chart configuration object
Parameters

chartConfig

object

Optional chart configuration object. If not supplied the grid chartConfig property is used.

Run Sample

columnValue(columnName, row)

Returns the grid value for the specified column name and grid row.
Parameters

columnName

string

Name of the column

row (optional)

object

Reference to the grid row. If not supplied the currently selected row is used.

Run Sample

executeQuery(sql, parameters)

Returns a array of objects containing column values for the selected database records. All property names are lowercase.
Parameters

sql

string

Sql statement to be executed

parameters

object

Parameter values for any parameter placeholders in the sql property

executeSingletonQuery(sql, parameters)

Returns an object containing column values for the selected database record. All property names are lowercase.
Parameters

sql

string

Sql statement to be executed

parameters

object

Parameter values for any parameter placeholders in the sql property

Run Sample

getDataArray(columnNames)

Returns an array of arrays representing the currently selected data in the grid. Data in the grid is returned as strings, dates and number types depending on the type of the database column.
Parameters

columnNames

array of strings

The names of the columns for which data should be returned (Optional). If not supplied then all columns are returned.

Run Sample

getInputControl(columnName, row)

Returns a reference to an input control when the grid is in edit mode.
Parameters

columnName

string

Name of the column

row

object

Reference to the row containing the required input element

initialize()

Initializes the control and returns the first page of data. The method is called after all the grid properties have been assigned.

Run Sample

loadData(primaryKey)

Reloads the current page of data or the page containing the primaryKey (if supplied)
Parameters

primaryKey (optional)

object

Column names and values that represent the primary key e.g. {CustomerID : "ANTON"}. If supplied the page containing the primary key will be returned and the row for the primary key selected.

Run Sample

 

refreshListOptions(columnName, options, row)

Refreshes the items in the drop-down list when the grid is in edit mode. The drop-down list is identified by columnName in the specified row. If options is specified then it can be either a JavaScript array or an SQL statement. If not specified the column lookup property is used to populate the list.
Parameters

columnName

string

Name of the column

options (optional)

array|string

Javascript array or SQL statement

row

object

Reference to the grid row containing the drop-down list

 

refreshRow()

Refreshes the currently selected row from the database

rowPrimaryKey()

Returns an object containing primary values for the currently selected row

selectedRows()

Returns an array of table row elements that are selected.

Run Sample

setColumnExpressions(columnNames)

Specifies the columns that are selected from the table or view specified in the fromPart property
Parameters

columnNames

array of strings

or

multiple strings

List of column names

 

	<script>
	jQuery(document).ready( init )

	function init()
	{
		var dbnetgrid1 = new DbNetGrid("dbnetgrid1");
		with (dbnetgrid1)
		{
			connectionString = "SamplesDatabase"
			fromPart = "Suppliers"
			setColumnExpressions("CompanyName","Address","City","Phone","Fax");
			setColumnLabels("Company Name","Addr","Town","Work Phone","Fax");
			initialize()
		}
	}

	</script>

Run Sample

setColumnFilter(columnName, value)

Sets the value of a column filter
Parameters

columnName

string

Name of the column associated with the column filter

value

string

Value to be assigned to the column filter

Run Sample

setColumnLabels(columnLabels)

Specifies the labels for the columns specified in setColumnExpressions
Parameters

columnLabels

array of strings

or

multiple strings

List of labels

 

	<script>
	jQuery(document).ready( init )

	function init()
	{
		var dbnetgrid1 = new DbNetGrid("dbnetgrid1");
		with (dbnetgrid1)
		{
			connectionString = "SamplesDatabase"
			fromPart = "Suppliers"
			setColumnExpressions("CompanyName","Address","City","Phone","Fax");
			setColumnLabels("Company Name","Addr","Town","Work Phone","Fax");
			initialize()
		}
	}

	</script>

Run Sample

setColumnProperty(columnName, propertyName, propertyValue)

Assigns a property value to the specified column (or columns)

Parameters

columnName

string|array of strings

Column name or array of column names

propertyName

string

Name of the column property

propertyValue

string, number or boolean

The property value

 

Setting an individual property for a single column

	<script>
	jQuery(document).ready( init )

	function init()
	{
		var dbnetgrid1 = new DbNetGrid("dbnetgrid1");
		with (dbnetgrid1)
		{
			connectionString = "SamplesDatabase"
			fromPart = "Orders"

			setColumnExpressions("CustomerID","EmployeeID","OrderDate","ShipVia","ShipCountry");
      setColumnProperty("CustomerID","label", "Customer");
      setColumnProperty("CustomerID","lookup", "select customerid, companyname from customers");
      setColumnProperty("CustomerID","filter", true);
      setColumnProperty("EmployeeID","label", "Employee");
      setColumnProperty("EmployeeID","lookup", "select employeeid, lastname from employees");
      setColumnProperty("EmployeeID","filter", true);
      setColumnProperty("OrderDate","filter", true);
      setColumnProperty("ShipCountry","filter", true);
      setColumnProperty("ShipVia","lookup", "select shipperid, companyname from shippers");
      setColumnProperty("ShipVia","filter", true);
			initialize()
		}
	}

	</script>

Setting an individual property for a multiple columns

	<script>
	jQuery(document).ready( init )

	function init()
	{
		var dbnetgrid1 = new DbNetGrid("dbnetgrid1");
		with (dbnetgrid1)
		{
			connectionString = "SamplesDatabase"
			fromPart = "Orders"

			setColumnExpressions("CustomerID","OrderID","OrderDate","Freight","RequiredDate");
      setColumnProperty(["OrderID","OrderDate","Freight"],"search",false)
			initialize()
		}
	}

	</script>

Run Sample

setColumnProperty(columnName, properties)

Assigns multiple property values to the specified column

Parameters

columnName

string|array of strings

Column name or array of column names

properties

object

Property names and values

 

Setting an multiple properties for a single column

	<script>
	jQuery(document).ready( init )

	function init()
	{
	
		var dbnetgrid1 = new DbNetGrid("dbnetgrid1");
		with (dbnetgrid1)
		{
			connectionString = "SamplesDatabase"
			fromPart = "Orders"

			setColumnExpressions("CustomerID","EmployeeID","OrderDate","ShipVia","ShipCountry");
			setColumnProperty("CustomerID",{label : "Customer", lookupSearchMode : "SearchText", lookup : "select CustomerID, CompanyName from Customers" })

			initialize()
		}
	}

	</script>

Run Sample

toolbarElement(id)

Gets a reference to the specified toolbar element.

Parameters

id

string

id can be quickSearch, search, updateRow, deleteRow, insertRow, navigation, pageInfo, rowInfo,columnPicker,userProfile, userProfileSelect, mailMerge, copy, print or save

Run Sample

toolButtonText(id, text)

Binds a client-side function to an event
Parameters

id

string

id can be quickSearch, search, updateRow, deleteRow, insertRow, navigation, pageInfo, rowInfo, columnPicker, userProfile, mailMerge, copy, print or save

text

string

Text to display in button

Run Sample