Files
datahub/docs/tutorial-basics-query.markdown
2012-07-04 14:52:12 +01:00

1.6 KiB

layout, title, recline-deps, root
layout title recline-deps root
container Tutorial - Dataset Basics true ../

Dataset Basics - Querying

Preparations

See first Dataset basics tutorial for getting setup and initializing Dataset.

<script type="text/javascript"> {% include data.js %} var dataset = new recline.Model.Dataset({ records: data }); </script>

Querying

The basic thing we want to do with Datasets is query and filter them. This is very easy to do:

{% highlight javascript %} {% include tutorial-basics-ex-2.js %} {% endhighlight %}

This results in the following. Note how recordCount is now 3 (the total number of records matched by the query) but that currentRecords only contains 2 records as we restricted number of returned records using the size attribute.

 
<script type="text/javascript"> $('.ex-2').html(''); {% include tutorial-basics-ex-2.js %} </script>

Full details of the query structure and its options can be found in the reference documentation.

Also worth noting is that the last run query is stored as a Query instance in the queryState attribute of the Dataset object. Modifying queryState will also resulting in a query being run. This is useful when building views that want to display or manage the query state (see, for example, Query Editor or Filter Editor widgets).