[ckan-dev] Rendering hierarchical datasets with Recline.js

Haq, Salman Salman.Haq at neustar.biz
Tue Jun 12 10:51:55 UTC 2012


Hi,

I have a question about using recline.js and since there is no official forum for it (that I know of), I'm posting it here.

Using ElasticSearch as the backend to store a hierarchical document with several nested lists, what is the preferred way to transform the document so that it is in a flat, tabular form that can be displayed by the Grid View?

So consider an ElasticSearch document like:

{ foo: '…', bar: [ {x: …, y: …, z: …}, {x: …, y: …, z: …}, {x: …, y: …, z: …} ]  }

I want to display the rows in 'bar' in the grid view with the constraint that only columns 'W' and 'X' are displayed, where the value of column 'W' derives from field 'foo' and is always the same for each row and the value of column 'X' derives from field 'x' in the hashes of list 'bar'.

That is to say, I want display a document that looks like this:

[ {W: …, X: …}, {W: …, X: …}, {W: …, X: …} ]

If I create the dataset as follows:

dataset = new recline.Model.Dataset( {url: '….' }, 'elasticsearch')

Can I transform it by explicitly fetching and querying the backend?

dataset.fetch().done(function() { dataset.query().done(function (data) {
// dataset.currentDocuments contains my complex document.
// Can I perform the transformation here?
}});
});

And then rendering it as a grid?

grid = new recline.View.Grid({model: dataset});

Such that the user can interact with the grid and edit values in column 'X' that will update the appropriate element in the ES document?

Thanks,
Salman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120612/b96ff1ec/attachment.html>


More information about the ckan-dev mailing list