Results 1 to 4 of 4

Thread: Why my TreeGrid is not populated (JSON + SOLR) ?

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    24

    Default Why my TreeGrid is not populated (JSON + SOLR) ?

    Dear All,

    I don't reach to populate my Tree-Grid with data from my solr server.
    I reach to get json data but nothing in my Tree-Grid.
    I use MVC structure.
    My store is defined in my tree-grid definition.

    I don't know why it doesn't work :'(

    If I comment the reader inside my store i haven't error message, and:
    console.log(this.proxy.reader.rawData.response.docs);
    answers a good json.

    If I uncomment the reader, i have this error !

    TypeError: obj.response is undefined

    return Function.prototype.constructor.apply(Function.prototype, args);
    it seems that this line is not ok:
    root: 'response.docs'

    Could you help me please to find the problem ?

    Thanks a lot !

    Below my other codes

    My Store:
    Code:
    Ext.define('MPortal.store.patent.Patents', {
        extend: 'Ext.data.TreeStore',
        model:  'MPortal.model.patent.Patent',
        proxy: {
            type:           'jsonp',
            url:            'http://www.my_solr_server.com/solr/select/',
            callbackKey:    'json.wrf',
            limitParam:     'rows',
            extraParams: {
                wt:         'json',
                'json.nl':  'arrarr',
                fl:         'pn,fid,pd',
                rows:       '10'
            },
            reader: {
                type: 'json',
                root: 'response.docs'
            }
        }
    });
    My Model
    Code:
    Ext.define('MPortal.model.patent.Patent', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'pn',    type: 'string'},
            {name: 'fid',   type: 'string'},
            {name: 'pd',    type: 'date'}
        ]
    });
    My tree-grid
    Code:
    Ext.define('MPortal.view.patent.MyPatentTreeGrid', {
        extend: 'Ext.tree.Panel',
        alias:  'widget.mypatenttreegrid',
    
        requires: [
            'Ext.data.*',
            'Ext.grid.*',
            'Ext.tree.*',
            'Ext.ux.CheckColumn',
            'MPortal.model.patent.Patent'
        ],    
    
        xtype: 'tree-grid',
        
        useArrows: true,
        rootVisible: false,
        multiSelect: true,
        singleExpand: true,
        
        initComponent: function() {
            Ext.apply(this, {
                store: 'MPortal.store.patent.Patents',
                columns: [
                    {
                    //xtype: 'treecolumn', //this is so we know which column will show the tree
                    text: 'Patent Number',
                    flex: 2,
                    dataIndex: 'pn',
                    sortable: true
                },{
                    text: 'Family Id',
                    flex: 1,
                    dataIndex: 'fid',
                    sortable: true
                },{
                    text: 'Pud. Date',
                    flex: 1,
                    dataIndex: 'pd',
                    sortable: true
                }
            ]
            });
            this.callParent();
        }
    });
    and now, the method I use to call it:

    Code:
    .....
            var mySearches = this.getTreePanel().getStore();
            mySearches.load({
                params: { q: mySolrQuery.value },
                callback: function(response) {
                    console.log("we searched");
                    console.log(this.proxy.reader.rawData.response.docs);
                    //console.log(response);
                    //var json = Ext.decode(this.proxy.reader.rawData.response.docs);
                    //console.log(json[0].pn);
                }
            });
    
    ...

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    What does your JSON data look like?

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    24

    Default

    sorry, my JSON is:

    Code:
    {   "responseHeader":{     "status":0,     "QTime":13,     "params":{       "indent":"true",       "wt":"json",       "rows":"10",       "fl":"pn,fid,pd",       "q":"ti:airbus"}},   "response":{"numFound":30,"start":0,"docs":[       {         "pn":"CN102381318A",         "pd":"2012-03-21T23:59:59Z",         "fid":"45821267"},       {         "pn":"CN202225867U",         "pd":"2012-05-23T23:59:59Z",         "fid":"46076469"},       {         "pn":"RU2111897C1",         "pd":"1998-05-27T23:59:59Z",         "fid":"20180416"},       {         "pn":"RU2021164C1",         "pd":"1994-10-15T23:59:59Z",         "fid":"21512596"},       {         "pn":"CN101346573A",         "pd":"2009-01-14T23:59:59Z",         "fid":"37489847"},       {         "pn":"US6508401B1",         "pd":"2003-01-21T23:59:59Z",         "fid":"9542691"},       {         "pn":"CN202270361U",         "pd":"2012-06-13T23:59:59Z",         "fid":"46190753"},       {         "pn":"RU2104215C1",         "pd":"1998-02-10T23:59:59Z",         "fid":"20156813"},       {         "pn":"RU94020963A",         "pd":"1996-07-10T23:59:59Z",         "fid":"20156813"},       {         "pn":"CN101811320A",         "pd":"2010-08-25T23:59:59Z",         "fid":"42618755"}]   }}

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    24

    Default

    Dear All,

    I try another way to populate my tree-grid. I use now a PHP file to have this kind of answer:

    Code:
    Array (     [responseHeader] => Array         (             [status] => 0             [QTime] => 0             [params] => Array                 (                     [indent] => true                     [wt] => json                     [rows] => 10                     [fl] => pn,fid,pd                     [start] => 0                     [q] => ti:airbus                 )          )      [response] => Array         (             [numFound] => 30             [start] => 0             [docs] => Array                 (                     [0] => Array                         (                             [pn] => CN102381318A                             [pd] => 2012-03-21T23:59:59Z                             [fid] => 45821267                         )                      [1] => Array                         (                             [pn] => CN202225867U                             [pd] => 2012-05-23T23:59:59Z                             [fid] => 46076469                         )                      [2] => Array                         (                             [pn] => RU2111897C1                             [pd] => 1998-05-27T23:59:59Z                             [fid] => 20180416                         )                      [3] => Array                         (                             [pn] => RU2021164C1                             [pd] => 1994-10-15T23:59:59Z                             [fid] => 21512596                         )                      [4] => Array                         (                             [pn] => CN101346573A                             [pd] => 2009-01-14T23:59:59Z                             [fid] => 37489847                         )                      [5] => Array                         (                             [pn] => US6508401B1                             [pd] => 2003-01-21T23:59:59Z                             [fid] => 9542691                         )                      [6] => Array                         (                             [pn] => CN202270361U                             [pd] => 2012-06-13T23:59:59Z                             [fid] => 46190753                         )                      [7] => Array                         (                             [pn] => RU2104215C1                             [pd] => 1998-02-10T23:59:59Z                             [fid] => 20156813                         )                      [8] => Array                         (                             [pn] => RU94020963A                             [pd] => 1996-07-10T23:59:59Z                             [fid] => 20156813                         )                      [9] => Array                         (                             [pn] => CN101811320A                             [pd] => 2010-08-25T23:59:59Z                             [fid] => 42618755                         )                  )          )  )
    but of course, it don't work :''(

    I get this error:
    SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help)

    Array" class="errorSourceCode ">[responseHeader] => Array
    with this proxy:

    Code:
    Ext.define('MPortal.store.patent.Patents', {
        extend: 'Ext.data.TreeStore',
        model:  'MPortal.model.patent.Patent',
        root:{ //pour que le panel Soit vide au dpart
            expanded:false,
            children:[]
        },
        proxy: {
            type:           'jsonp',
            url:    'http://www.MYSERVER.com/xxxxx/search.php',
            reader: {
                type:           'json',
                totalProperty:  'numFound',
                root:           'response' //.responseHeader' //.docs'
            }
        }
    });
    Any idea will welcome

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •