簡體   English   中英

從JsonStore提供數據視圖

[英]Feeding the dataview from JsonStore

從jsonstore提供viewdata

我想使用JsonStore來提供我的數據視圖。 目前使用下面的代碼,數據視圖中的商店是空的。 為了測試,我在打開窗口之前在控制器中編寫了一些代碼,我可以看到restful服務檢索數據 - getActivitiesToRescueCallback --> responce.responseText 如何使用Jsonstore提供數據視圖?

在ViewController中:

getActivitiesToRescueCallback : function(options, success, response) {
    if (success)
        var result = Ext.decode(response.responseText); // Here I am getting data

},

getActivitiesToRescue : function() {
    Ext.Ajax.request({
        url : '/test/json_p',
        params : {
            "params[]" : "RESCUE",
            "respName" : "",
            "method" : "GetActivities",
            "format" : "json"
        },
        callback : 'getActivitiesToRescueCallback',
        scope : this
    });
},
**View**
Ext.define('Tuv.test.rescue.RescueView', {

extend : 'Ext.window.Window',

alias : 'widget.rescueview',

alias : 'controller.rescueview',

bind : {
    title : '{rescueTexts.masseRescue}'
},

height : 400,

width : 600,

constrainHeader : true,

maximizable : true,

closeAction : "hide",

layout : 'card',

activeItem : 0,

items : [ {
    xtype : 'panel',
    title : 'check activities',
    layout : 'hbox',
    border : false,
    layoutConfig : {
        align : 'stretch'
    },
    tbar : [ {
        xtype : "button",
        text : "copy",
        handler : function() {},
        scope : this
    } ],
    items : [ {
        autoScroll : true,
        width : 150,
        items : {
            xtype : 'dataview',
            listeners : {
                'afterrender' : function(comp) {
                    console.log('Test');
                },
                scope : this
            },
            store : new Ext.data.JsonStore({
                url : '/test/json_p',
                baseParams : {
                    "params[]" : "RESCUE",
                    respName : "",
                    method : "GetActivities",
                    format : "json"
                },
                idProperty : 'ACT_ID',
                fields : [ 'ACT_ID', '_ACT_TYPE', '_FIRST_FORM', 'PRUEFSTATUS', '_DEBUG', '_SYNC_STATUS', '_SYNC_STATUS2', 'EQART', 'INVNR', 'ZTSPRID', 'ANLAGE_ZTSPRID', 'ZTSPRIDT' ]
            }),
            itemSelector : 'tr.dataRow',
            tpl : new Ext.XTemplate('<table id="dataRescueTable">' + '<tpl for=".">', '<tr class="dataRow"><td>' + '<span <tpl if="STATUS==50">style="font-weight: bold;color:green"</tpl>>{name}</span></td></tr>', '</tpl>', '</table>')
        }
    } ],
    bbar : {
        buttonAlign : 'right',
        items : [ {
            text : "next",
            handler : function(button) {

            },
            scope : this
        } ]
    }
} ]

});

要加載商店,我必須調用store.load()或將autoLoad: true添加為商店的配置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM