From 19f14c950708aa50b71600d19f40a0b2c0c1056b Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Fri, 29 Jun 2012 20:29:10 +0100 Subject: [PATCH] [tutorial/views][s]: bring the tutorial up to date and switch to slickgrid for the grid. --- docs/tutorial-views.markdown | 107 ++++++++++++++++------------------- 1 file changed, 50 insertions(+), 57 deletions(-) diff --git a/docs/tutorial-views.markdown b/docs/tutorial-views.markdown index 88fbf561..750bb065 100644 --- a/docs/tutorial-views.markdown +++ b/docs/tutorial-views.markdown @@ -40,10 +40,6 @@ Before writing any code with Recline, you need to do the following preparation s --> {% endhighlight %} -4. Create a div to hold the Recline view(s): - {% highlight html %} -
{% endhighlight %} - You're now ready to start working with Recline. ### Creating a Dataset @@ -61,37 +57,62 @@ no reason you cannot have objects as values allowing you to nest data. We can now create a recline Dataset object (and memory backend) from this raw data: {% highlight javascript %} -var dataset = recline.Backend.Memory.createDataset(data); +var dataset = new recline.Model.Dataset({ + records: data +}); {% endhighlight %} -Note that behind the scenes Recline will create a Memory backend for this dataset as in Recline every dataset object must have a backend from which it can push and pull data. In the case of in-memory data this is a little artificial since all the data is available locally but this makes more sense for situations where one is connecting to a remote data source (and one which may contain a lot of data). - ### Setting up the Grid -Let's create a data grid view to display the dataset we have just created, binding the view to the `
` we created earlier: + +Let's create a data grid view to display the dataset we have just created. We're going to use the SlickGrid-based grid so we need the following: + +{% highlight html %} + + + + + + + + + +{% endhighlight %} + +Now, let's create an HTML element to for the Grid: + +{% highlight html %} +
+{% endhighlight %} + +Now let's set up the Grid: {% highlight javascript %} var $el = $('#mygrid'); -var grid = new recline.View.Grid({ - model: dataset +var grid = new recline.View.SlickGrid({ + model: dataset, + el: $el }); -$el.append(grid.el); +grid.visible = true; grid.render(); {% endhighlight %} And hey presto: -
 
+
 
@@ -107,7 +128,7 @@ library and the Recline Graph view: - + {% endhighlight %} Next, create a new div for the graph: @@ -116,35 +137,15 @@ Next, create a new div for the graph:
{% endhighlight %} -Now let's create the graph, we will use the same dataset we had earlier: +Now let's create the graph, we will use the same dataset we had earlier, and we will need to set the view 'state' in order to configure the graph with the column to use for the x-axis ("group") and the columns to use for the series to show ("series"). -{% highlight javascript %} -var $el = $('#mygraph'); -var graph = new recline.View.Graph({ - model: dataset -}); -$el.append(grid.el); -graph.render(); -{% endhighlight %} - -And ... we have a graph view -- with instructions on how to use the controls to -create a graph -- but no graph. Go ahead and play around with the controls to -create a graph of your choosing: - -
 
- - - -But suppose you wanted to create a graph not a graph editor. This is -straightforward to do -- all we need to do is set the 'state' of the graph -view: +
+State: The concept of a state is a common feature of Recline views being an object +which stores information about the state and configuration of a given view. You +can read more about it in the general Views +documentation as well as the documentation of individual views such as the +Graph View. +
{% highlight javascript %} var $el = $('#mygraph'); @@ -159,12 +160,12 @@ $el.append(graph.el); graph.redraw(); {% endhighlight %} -We would get this rendered graph: +The result is the following graph: -
 
+
 
-
-State: The concept of a state is a common feature of Recline views being an object -which stores information about the state and configuration of a given view. You -can read more about it in the general Views -documentation as well as the documentation of individual views such as the -Graph View. -
- ### Creating a Map Now, let's create a map of this dataset using the lon/lat information which is