DBView Class

Component used to compile queries and view results in a table. The component consists of three elements: a list of tables on the left, a query editor in the center, and a table/grid on the bottom (below the editor). Queries are executed on the server via REST web services. The queries are queued by the server and executed asynchronously. The server provides web methods to submit jobs, check job status, and pick up completed jobs. See the javaxt.express.services.QueryService class for more information.

Constructors

DBView( parent, config )
Used to instantiate this class
parentDOM element in which to render this component
configConfiguration settings (optional). See config options for more information.

Config Options

queryLanguage
If the CodeMirror library is available, it will be used as the query editor (vs default textarea). You can specify a coding language to use with CodeMirror (e.g. sql, cypher, etc). Default is sql.
queryService
Path to REST endpoint used to create, get, and delete query jobs. This path may be overridden via the createJob, getJob, and cancelJob config.
getTables
Path to REST endpoint that returns a list of tables. Alternatively, you can provide a function with a callback.
createJob
Path to REST endpoint used to create a query job. Alternatively, you can provide a function that executes a "POST" request.
cancelJob
Path to REST endpoint used to delete/cancel a query job. Note that the "{jobID}" will be replaced with an actual id. Alternatively, you can provide a function that executes a "DELETE" request. The function should return an XHR request.
getJob
Path to REST endpoint that returns results of a query job. Note that the "{jobID}" will be replaced with an actual id. Alternatively, you can provide a function that executes a "GET" request. The function should return an XHR request.
pageSize
Used to specify the page size (i.e. the maximum number records to fetch from the server at a time)
format
Used to specify the response format for the query results. Options include "json", "csv", "tsv, and "jsv"
style
Style for individual elements within the component. Note that you can provide CSS class names instead of individual style definitions.
onTreeClick
By default, when a user clicks on a node in the tree, the query editor is updated with a default query statement for the node. You can update this default behaviour by providing a custom function.

Public Methods

setQuery( query )
Used to update the query in the query editor. Will clear records in the table from any previous query.
getQuery( )
Returns text from the query editor
executeQuery( )
Used to execute a query by submitting whatever is in the query editor to the server. Note that there is no client-side validation.
clear( )
Used to remove text from the query editor and clear the results table.
clearResults( )
Used to clear the results table.
getComponents( )
Returns a json object with individual components that make up this component.
  • tree: javaxt.dhtml.Tree used to render table names
  • grid: javaxt.dhtml.DataGrid used to render query results
  • editor: the component used edit queries
  • toolbar: DOM object (table) with buttons