1. #1
    Sencha Premium Member Fredric Berling's Avatar
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    186
    Vote Rating
    15
    Fredric Berling has a spectacular aura about Fredric Berling has a spectacular aura about

      0  

    Thumbs up Getting data using the outputformat=JSON parameter

    Getting data using the outputformat=JSON parameter


    I have been testing getting grid data using Dominos new parameter for JSON. Its quite nice and suits well for lots of things. especially small amounts of documents or responses in "embedded view" type fashoin.

    You will reqognice most of the code from a previous post about jsonreader but here we go.

    NOTE!! outputformat=JSON is only available in Domino 7.02 and above. but then..Who wouldnt upgrade to at least 7.02 anyway..right?!!

    NOTE 2!! outputformat=JSON can be combined with the usual parameters fro readviewentries


    Simple form with Ext initializing in HTMLHead and some passthrue HTML in body. nothing else
    PHP Code:
    <div style="margin-left:100px;margin-top:50px">
       <
    div id="file-grid" style="border:1px solid #99bbe8;overflow: hidden; width: 400px; height: 300px;"></div>
    </
    div
    Create a View named "testjson" with a single column populated with a text describing the document.

    Here is the code from the forms onLoad event
    PHP Code:
    // JavaScript Document
    var jsonReader;
    var 
    myDataStore;

    Ext.onReady(function()
    {
        
    jsonReader = new Ext.data.JsonReader({
               
    root'viewentry',
               
    totalProperty'@toplevelentries',
               
    id'id',
               
    fields: [{name:'@position'type:'int'},{name:'unid'mapping:'@unid'},{name'description'mapping'entrydata[0].text[0]'}]
        });
                    
        
    myDataStore = new Ext.data.Store({
            
    proxy: new Ext.data.HttpProxy({
                
    url'testjson?ReadViewEntries&outputformat=JSON',
                
    method'POST'
            
    }),
            
    readerjsonReader,
          
    autoLoadtrue,
            
    remoteSortfalse
        
    });
        
        function 
    renderTitle(valueprecord) {
              return 
    String.format('<a href="#" onClick="javascript:AddProperty({1})">{0}</a>',
              
    valuerecord.data.unid);
         }
        function 
    renderBold(value) {
            return 
    '<B>'value '</B>';
         }
        
        var 
    colModel = new Ext.grid.ColumnModel( [
                 {
    header"id"width100sortable:'true'resizablefalserenderer:renderBold,dataIndex'@position'},
              {
    header"name"width220resizablefalsedataIndex'unid'},
              {
    header"Descripion"width220resizablefalserenderer:renderTitledataIndex'description'}
        ]);

             
        var 
    grid = new Ext.grid.GridPanel({
            
    renderTo:'file-grid',
            
    store:myDataStore,
            
    colModel:colModel,
            
    viewConfig: {
                
    forceFittrue
            
    },
            
    sm: new Ext.grid.RowSelectionModel({singleSelect:false}),
                
    width:600,
                
    height:300,
                
    frame:true,
                
    title:'Test',
                
    iconCls:'icon-grid'
            
    });
                    
        
    grid.render();
        
    grid.on('rowdblclick', function(){
            var 
    selection grid.getSelectionModel().getSelected();
            
    alert(selection.data.description);     
        });
    }) 
    Personally i find the renderer stuff especially awesome, and that you have the complete record in the "record" variable. And also later in the "selection" variable gotten from "grid.getSelectionModel().getSelected();" .. SO USEFUL!!

    The "mapping" config in the jsonreader field section are very useful for extracting the correct column from the entrydata array, but still be able to use a readable variable name for the column.

    Its possible this way is faster compared to getting the data using an agent and when it comes to encoding and strange character sets i beleive we can run into trouble by forcing the charset like we do in the agent variant. The outputformat=JSON has all possibilities to deal with this in the appropriate way since its built in.

    I hope more Ext newbies find this example valuable.

  2. #2
    Sencha - Training Team RWaters's Avatar
    Join Date
    Mar 2007
    Location
    Los Angeles, CA
    Posts
    714
    Vote Rating
    0
    RWaters is on a distinguished road

      0  

    Default


    Nice Example Fredric, thanks! We would personally love to switch Ext.nd over to JSON but we want to maintain support for those who are stuck in companies that can't/wont upgrade.

    Just wanted to mention that we've been continuing work on the new version and have the ability for developers to provide custom renderers as well now. Previously we had been putting everything through the single 'dominoRenderer' that we wrote and you had to hack that one up to make any changes.

  3. #3
    Sencha Premium Member Fredric Berling's Avatar
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    186
    Vote Rating
    15
    Fredric Berling has a spectacular aura about Fredric Berling has a spectacular aura about

      0  

    Smile


    Nice to know you are also thinking JSON when it comes to Ext.nd. Cant help but wondering how many companies that are ready to put effort into making Web 2.0 applications out of their databases but NOT willing to upgrade to 7.02.

    But its just me thinking again...

  4. #4
    Sencha User
    Join Date
    Oct 2008
    Posts
    64
    Vote Rating
    0
    daddyschmack is on a distinguished road

      0  

    Default Has Anything changed for ext 2.2. and Notes 8?

    Has Anything changed for ext 2.2. and Notes 8?


    I have tried to mock this model exactly, but I keep getting an error, H is null.

    Should this work with ext 2.2 and notes 8. (local preview)

    I'm trying to figure out how to make this data store with with json so I can create a new way to populate an ajax combo box. If you use readviewentries, one should be able to get around the "weird" sorting currently seen when using the viewEntryCollection and documentcollection classes.

    Here is the error from firebug..

    H is null
    initComponent()(null, null)ext-all.js (line 76)
    GridView()(null, null)ext-all.js (line 143)
    Action()("file-grid", undefined)ext-all.js (line 58)
    ContainerLayout()()ext-all.js (line 64)
    Action()(Object renderTo=file-grid store=Object colModel=Object)ext-all.js (line 58)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    (?)()JsonView...?OpenForm (line 101)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()(0, undefined, undefined, undefined)ext-base.js (line 9)
    camelFn()(renderTitle(value, p, record), undefined, Object)ext-all.js (line 13)
    onload()JsonView...?OpenForm (line 11)

    [IMG]chrome://firebug/content/blank.gif[/IMG]Ext.Panel=Ext.extend(Ext.Container,{base...utoLoad})}});Ext.reg("panel",Ext.Panel);

    Thanks,

    John

  5. #5
    Ext User mdm-adph's Avatar
    Join Date
    May 2007
    Posts
    187
    Vote Rating
    0
    mdm-adph is on a distinguished road

      0  

    Default


    Quote Originally Posted by Fredric Berling View Post
    Nice to know you are also thinking JSON when it comes to Ext.nd. Cant help but wondering how many companies that are ready to put effort into making Web 2.0 applications out of their databases but NOT willing to upgrade to 7.02.

    But its just me thinking again...
    Sometimes when you have tens of thousands of users to support, and hundreds of old legacy applications, it can take years to upgrade even to the next minor version. Just the way it is.

    However, keep up the work working with Domino's JSON output! It's actually faster than getting the information via XML -- I can't remember where I found, but there's an examination that someone did out there on the interwebs where they extensively tested the speed at which view queries were returned from the Domino server in both XML and JSON formats, and JSON consistently won.

    I use it for all my apps, though I leave an easy way to fallback to XML if necessary by just having an alternate Ext.Reader handy.
    Prototype, jQuery,
    YUI, Ext.
    I code for the piles of money
    I'd like to one day see.

  6. #6
    Ext User
    Join Date
    Feb 2008
    Posts
    10
    Vote Rating
    0
    roudoudou is on a distinguished road

      0  

    Default


    Quote Originally Posted by daddyschmack View Post
    I have tried to mock this model exactly, but I keep getting an error, H is null.

    Should this work with ext 2.2 and notes 8. (local preview)

    I'm trying to figure out how to make this data store with with json so I can create a new way to populate an ajax combo box. If you use readviewentries, one should be able to get around the "weird" sorting currently seen when using the viewEntryCollection and documentcollection classes.

    Here is the error from firebug..

    H is null
    initComponent()(null, null)ext-all.js (line 76)
    GridView()(null, null)ext-all.js (line 143)
    Action()("file-grid", undefined)ext-all.js (line 58)
    ContainerLayout()()ext-all.js (line 64)
    Action()(Object renderTo=file-grid store=Object colModel=Object)ext-all.js (line 58)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()()ext-base.js (line 9)
    (?)()JsonView...?OpenForm (line 101)
    getViewWidth()()ext-base.js (line 9)
    getViewWidth()(0, undefined, undefined, undefined)ext-base.js (line 9)
    camelFn()(renderTitle(value, p, record), undefined, Object)ext-all.js (line 13)
    onload()JsonView...?OpenForm (line 11)

    [IMG]chrome://firebug/content/blank.gif[/IMG]Ext.Panel=Ext.extend(Ext.Container,{base...utoLoad})}});Ext.reg("panel",Ext.Panel);

    Thanks,

    John
    Hello
    I had the same problam as you with Domino 8 + ext 2.2.
    I chaged the html code as bellow :

    <div id="file-grid"></div>

    And now the error message disapears.

  7. #7
    Ext User DServe's Avatar
    Join Date
    May 2007
    Location
    Grenoble, France
    Posts
    23
    Vote Rating
    0
    DServe is on a distinguished road

      0  

    Default Domino URL parameters

    Domino URL parameters


    Thank you Fredric, very useful this example!

    I'm currently working on this subject and try to integrate Domino's native paging system.
    For this I set
    PHP Code:
    paramNames:{start'start'limit'count' 
    property of PagingToolbar, and it works like a charm. Except...

    In Domino the URL below returns only the @toplevelentries property :
    PHP Code:
    http://server/path/db.nsf/view?readviewentries&outputformat=json&preformat&start=0&count=25 
    So I have to set the start parameter to 1, but the PagingToolbar component has no parameter allowing me to set the start index (the first page 'first' and 'previous' buttons are active, and the count is 'Documents 2 to 26 on 150' instead of 'Documents 1 to 25 on 150').

    I think I'll have to derive my own PagingToolbar but if anyone as a simple trick....

  8. #8
    Sencha User
    Join Date
    Sep 2010
    Posts
    56
    Vote Rating
    1
    Bob Wilson is on a distinguished road

      0  

    Default Domino view + readviewentries + grid

    Domino view + readviewentries + grid


    Hi all,

    Since Ext 4.1 remapped most of the grid configs, I wonder if there is somewhere a working example of how to deal with "Domino views + readviewentries + ext grid".

    I have (over) looked at the forums, but we can only find old versions of components that uses deprecated methods.

    Is there an updated version of "domino view to grid component" ?

    Regards.

  9. #9
    Sencha User
    Join Date
    Sep 2010
    Posts
    56
    Vote Rating
    1
    Bob Wilson is on a distinguished road

      0  

    Default Here is what's I've tried

    Here is what's I've tried


    I've tried to apply the same principle with Ext 4.1 objects, but I can't even load the store.

    Here is a very simple example (not working) :

    Code:
    jsonReader = Ext.create('Ext.data.reader.Json', { 
       id: 'id',
       root: 'viewentry', 
       totalProperty: '@toplevelentries', 
       fields:
       [
                {name:'position',        mapping: '@position'},
                {name:'unid',             mapping:'@unid'},
                {name:'description',      mapping: 'entrydata[0].text[0]'}
       ] 
    }); 
                     
    myDataStore = Ext.create('Ext.data.Store', { 
       proxy: {
          type: 'ajax',
          url: '../lookupResourcesByName?ReadViewEntries&outputformat=JSON',
          reader: jsonReader
       },
    
       fields: ['position', 'unid', 'description'],
       autoLoad: true
    });
    
    
    console.log(myDataStore);
    This code returns an empty store in the console log.
    Using chrome Network tracking, I can see that the server response is like this :

    Code:
    {
    "@timestamp": "20120621T094711,17Z",
    "@toplevelentries": "4"
    }
    I must miss something obvious, because when I'm using the exact same URL in the browser, I get this :

    Code:
    {
        "@timestamp": "20120621T094922,72Z",
        "@toplevelentries": "4",
        "viewentry": [
        {
            "@position": "1",
            "@unid": "A30CE56AF0D8C53144257A11004ECFC0",
            "@noteid": "1B66",
            "@siblings": "4",
            "entrydata": [
            {
                "@columnnumber": "0",
                "@name": "name",
                "text": {
                    "0": "Resource A"
                }
            }
            ]
        },
        {
            "@position": "2",
            "@unid": "5561A36406F4477244257A11004F8596",
            "@noteid": "1B6A",
            "@siblings": "4",
            "entrydata": [
            {
                "@columnnumber": "0",
                "@name": "name",
                "text": {
                    "0": "Resource B"
                }
            }
            ]
        },
        {
            "@position": "3",
            "@unid": "D6BA9D1324F1909844257A1A0079671B",
            "@noteid": "1D9E",
            "@siblings": "4",
            "entrydata": [
            {
                "@columnnumber": "0",
                "@name": "name",
                "text": {
                    "0": "Resource C"
                }
            }
            ]
        },
        {
            "@position": "4",
            "@unid": "6A4317E51CF4CFBB44257A1A0052E36D",
            "@noteid": "1D9A",
            "@siblings": "4",
            "entrydata": [
            {
                "@columnnumber": "0",
                "@name": "name",
                "text": {
                    "0": "Resource D"
                }
            }
            ]
        }
        ]
    }
    Last edited by Bob Wilson; 21 Jun 2012 at 2:10 AM. Reason: Edit broken tabulations

  10. #10
    Sencha User
    Join Date
    Oct 2008
    Posts
    64
    Vote Rating
    0
    daddyschmack is on a distinguished road

      0  

    Default You're using ext 4.x and Domino?

    You're using ext 4.x and Domino?


    Gentlemen,
    I haven't tried Ext.nd since 2009. Are you guys actually making this work? That is impressive. How is the performance on the view grid when generated by an agent. I always found that to be a bit laggy.

    Thanks,

    John

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi