1. #1
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    18
    Vote Rating
    2
    HansGroeneveld is on a distinguished road

      0  

    Default Created dataview does not show data

    Created dataview does not show data


    I try to show a dynamic result set in a dataview.
    In a store 'Headers' I have loaded all the columns that have to be loaded in a new (json) store.
    In the onStoreLoad event of the store 'Headers' I have code shown below.

    The problem is that the created dataview does not show any fields. When I look in Chrome (developer tools) I see that the created store does have data.
    When I force the webservice to give no results then I get the text 'No data', that is the correct value from the property emptyText. So, the dataview is visible.
    It seems that the binding between store and dataview is not correct. The fieldnames are correct.

    What is wrong in this code?


    Code:
    var tpl = '';
    var fields = new Ext.data.Field();
    var max = records.length;
    for (var i = 0; i < max; i++)
    {
        var field = new Ext.data.Field({
            name: records[i].get('cname')
        });
        tpl = tpl + '{' + records[i].get('cname') + '} ';
        fields[i] = field ;
    }
    var store = new Ext.data.Store({
        proxy: {
            type: 'jsonp',
            url : 'http://tspalm/toolkit/callback.php?level=9&commandid=' + MyApp.sqlCommandId + '&viewid=' + MyApp.sqlView,
            reader: {
                type: 'json'
            }
        },
        fields: fields
    });
    
    var dv = new Ext.DataView({
            store: store,
            height: 445,
            emptyText: 'No data',
            itemTpl: tpl,
            tpl: new Ext.XTemplate(
            '<tpl for=".">',
                '<div class="item">'+ tpl + '</div>',
            '</tpl>'
        )});
        
    var panel = new Ext.Panel({
        id:'myview',
        alias: 'widgets.resultsview',
        layout:'vbox',
        fullscreen: true,
        title:'Results',
    
        items: [
            dv,
            {
                xtype: 'button',
                text: 'Refresh',
                handler: function()
                {
                    store.load();
                }
            }
        ]
    });
    
    store.load();
    var  p = Ext.getCmp('mynavigationview');
    p.push(panel);

  2. #2
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    This does not look like clean code produced by sencha architect. Are you sure that you posted in the proper forum?

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    18
    Vote Rating
    2
    HansGroeneveld is on a distinguished road

      0  

    Default


    Yes, this code from onLoad event of a store. An event, so manually typed.
    The problem is that I have to consume webservices from a backend database, these webservices are dynamically. I do not know at this moment what the columns will be, however the backend does have a possibility to return the column names and type. With that I build a new store to consume the dynammically webservice.
    The code so far that the dynamically store retrieves the data, the view does have the correct store and the fields do have the correct name. Still there is no data showned, only when there is no data received I see the 'No data' text.
    I am very very close, but that is for days now. My trial is ending over a week so I hope to get an answer if it is possible with Sencha to create dynamically stores and views, if so how..?

Thread Participants: 1

Tags for this Thread