Login Register

A *working* example of displaying a Domino view in a Dojox Grid?

I have been beating myself to death trying to figure out how to get the content of a Domino view to display in a dojox grid. It would be a HUGE win for Domino developers everywhere if someone could please post a *working* example of how to code this process from start to finish (or even better, a downloadable .nsf example). I've found snippets of little pieces of the puzzle, but nobody has posted a complete example that actually *works* ;) .

Here's what I've found out are the key elements so far:

* A domino view URL will return the view data in XML format when ?ReadViewEntries is appended to the URL.
* A domino view URL can also return data in JSON format when ?ReadViewEntries&OutputFormat=JSON is appended.
* Unfortunately the data is returned in a form that dojo doesn't know how to read. So an xsl or other type of transformation must be performed on the data.
* the transformed data must then be somehow be placed in a "dojo data model" object so the grid can display it (I haven't found any complete/working examples of that, either).

...every attempt I've made to link the different pieces of the puzzle together have failed (and we're probably talking > 100 attempts here). Has ANYONE actually succeeded at doing this? If so, PLEASE post! :)

Made a little progress

I've been making some progress... if I can get a little help on this part I think I can get it working. I've been reading this page:
http://www.sitepen.com/blog/2007/11/06/simple-dojo-grids/

I was able to build a working example of the grid on this page in Domino: http://blog.sitepen.com/examples/dojo_grid_1/grid_basic.html

...but it only works if I use their data.js and key in the subrow data they list in the example. If I try to replace data and subrow with data from domino... I get a blank square, and the browser status bar reveals this error when clicked:

Line:21
Char:16290
Error:'this.data.0.length' is null or not an object
Code:0

...if I remove the line:

... the page runs error-free (all other javascript on the page is running with no errors).

To get the data from Domino,
I've built a function that calls an xsl that converts the XML from the ?ReadViewEntries output into this (in an attempt to duplicate the table format used in the data.js example file):

[ [ "field1data", "field2data", "field3data", "field4data", "field5data"], [ "field1data", "field2data", "field3data", "field4data", "field5data"], [ "field1data", "field2data", "field3data", "field4data", "field5data"], [ "field1data", "field2data", "field3data", "field4data", "field5data"], [ "field1data", "field2data", "field3data", "field4data", "field5data"] ]

...I store the function's output like so:

var data = getViewData();

...I then call a function that uses a 2nd xsl that converts the XML from the ?ReadDesign output into this:

[ { name: 'data1' } , { name: 'data2' } , { name: 'data3' } , { name: 'data4' } , { name: 'data5' } ]

...and I store the function's output like so:

var subrow = getColumns();

...the intent being for the column names to dynamically change depending on what Domino view is selected (I need to avoid hard-coding the column names).

I then have the following code included in the jsheader:

var model = new dojox.grid.data.Table(null, data);

		var view = {
			rows: [ subrow ]
		};

		var structure = [
			view
		];

...and then I have this in the HTML of the page (attempt 145... yes, I'm keeping count), just like the example (and I'm using the same css too):

Domino View

... but the grid shows up as a blank square and the error I gave above.

If I insert a document.write(data) and a document.wrote(subrow) to output the data from my two xsl transformation functions to the browser, I get the data I copy-pasted above (the data is directly copy-pasted from my browser).

If I replace the content of data and subrow with the data.js and the hardcoded entry from the source of http://blog.sitepen.com/examples/dojo_grid_1/grid_basic.html, the grid works with no other changes to the page.

So my question is... what needs to change in how or what I'm storing in data and/or subrow in order to get the grid to run?

figured it out

HA! I figured it out. :)

My var statement was assigning the output of the xsl functions as a single string instead of evaluating it as a list of objects... dojo was expecting a table of objects. I wrapped an eval() around the function's output so it would evaluate it as a list of objects instead of a string, and BAM... it started working. BANZAI! I'll post the code after I get it cleaned up.

re: A *working* example of displaying a Domino view in a Grid

Have you cleaned up your code yet? Can you now paste it? It would help us a lot.

Still working on it

I'm running into a snag: ?ReadViewEntries does want to return more than 1000 records at once. I'll have to do some Domino research to figure out how to get it to allow more data (I'm trying to get it to return 3000 rows).

1000 Records at a time is a Server Document setting

Check tab "Internet Protocols",
then tab "Domino Web Engine",
then field "Maximum search result limit:"

if you enter 0 (zero) it means "no limit".