2

I have a xPage with following content:

<xe:restService id="restService" preventDojoStore="false">
    <xe:this.service>
        <xe:viewJsonService viewName="vwChartData"
            contentType="text/json">
            <xe:this.columns>
                <xe:restViewColumn columnName="x" name="valuex"></xe:restViewColumn>
                <xe:restViewColumn columnName="y" name="valuey"></xe:restViewColumn>
            </xe:this.columns>
        </xe:viewJsonService>
    </xe:this.service>
</xe:restService>

How to fetch the data after page load? From what I understand it should create a Dojo store, although it never loads the data.

When I add to the page a xe:djxDataGrid, hide it from user, I can easily access the data from created Dojo Store, either by referring directly the restService variable, or through djxDataGrid.

Solution:

<xp:scriptBlock>
    <xp:this.value><![CDATA[XSP.addOnLoad( function() {
    var ds = eval('restService');
    ds.fetch({
        onComplete : function(items, request) {
            console.log(items);
        }
    });
});]]></xp:this.value>
</xp:scriptBlock>
Jeremy Hodge
  • 1,655
  • 9
  • 8
Egor Margineanu
  • 740
  • 5
  • 9

1 Answers1

2

When you look at the source code when using a data grid you would see all the source code necessary to link your Dojo store. Watch the XSP.onLoad for trigger code.

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • In addition used http://www.ibm.com/developerworks/java/library/wa-jsonreststore/?ca=drs- which helped me to understand how fetch method should be used. – Egor Margineanu Apr 09 '12 at 10:27