【问题标题】:Issues connected with update JsonStore ExtJs 3.4与更新 JsonStore ExtJs 3.4 相关的问题
【发布时间】:2014-09-17 05:49:55
【问题描述】:

我想在用户从组合框向服务器请求后显示一个包含错误详细信息的窗口。如果我有异常,我将它放在 json 对象中并发送到 cline 端。Json 对象是这样的。

 {
  {"error_message": "java.lang.NullPointerException: null"}    
  items: [] 
 }

这是我发送和接收数据的代码的一部分。我尝试在 JsonStor 的每个侦听器中聊天数据,但都不起作用,以下是实施。我使用的是 ExtJs 3.4。

this.folderNameStore = new Ext.data.JsonStore({
            proxy: new Ext.data.HttpProxy({
                url: this.config.folderNamesPath,
                method: 'GET',
                timeout: 120000
            }),
            listeners: {
                beforeload: {
                    fn: function() {
                        var informaticaRepositoryId = this.getInformaticaRepositoryId();
                        if (informaticaRepositoryId) {
                            this.folderNameStore.setBaseParam('informatica_repository_id', informaticaRepositoryId);
                        }
                    },
                    scope: this
                }
            },
            root: 'items',
            idProperty: 'folder_name',
            fields: ['folder_name']
        });
        // Custom rendering Template
        resultTpl = new Ext.XTemplate('<tpl for="."><div class="informatica_workflow_command_folder_name-finder-item finder-item  x-combo-list-item">', '<h2 class="name">{folder_name}</h2>', '</div></tpl>');

        this.folderNameComboBox = new Ext.form.ComboBox({
            allowBlank: false,
            applyTo: "informatica_workflow_command_folder_name",
            disabled: true,
            displayField: 'folder_name',
            forceSelection: false,
            hideTrigger: false,
            mode: 'remote',
            itemSelector: 'div.informatica_workflow_command_folder_name-finder-item',
            listClass: 'job-agents-combobox',
            listEmptyText: helpsys.locale.javascript.no_matching_record,
            loadingText: helpsys.locale.common.searching,
            minChars: 4,
            submitValue: false,
            store: this.folderNameStore,
            tpl: resultTpl,
            triggerAction: 'all',
            typeAhead: true,
            maxLength: 80,
            maxHeight: 400,
            autoCreate: {tag: 'input', type: 'text', maxlength: '80'},
            valueField: 'folder_name',
            itemSelected: false,
            oldValue: '',
            listeners: {
                change: function () {
                    this.updateFolderNameComboBox();
                },
                select: function () {
                    this.updateFolderNameComboBox();
                },
                keyup: function() {
                    this.updateFolderNameComboBox();
                },
                scope: this
            }
        });

        this.updateFolderNameComboBox = function () {
            if (this.folderNameComboBox.value == '') {
                this.workflowNameComboBox.markInvalid();
            } else {
                if (this.folderNameComboBoxValue != this.folderNameComboBox.getValue()) {
                    this.workflowNameComboBox.markInvalid();
                }

                this.workflowNameComboBox.store.removeAll();
                this.workflowNameComboBox.lastQuery = null;
                this.workflowNameComboBox.enable();

                this.folderNameComboBoxValue = this.folderNameComboBox.getValue();
            }
        };

【问题讨论】:

    标签: json extjs jsonstore


    【解决方案1】:

    添加一个在存储加载时调用的函数: Ext.data.StoreManager.lookup('folderNameStore').on('load', this.folderNameStoreLoaded);

    然后在函数中执行类似 Ext.getStore('folderNameStore').proxy.reader.jsonData 的操作

    然后你可以在 if 语句中做你的弹出通知,比如 if (success == "error") { Ext.MessageBox.alert('Oh No', 'Oh No!.');}

    希望对您有所帮助。

    【讨论】:

    猜你喜欢
    • 2011-11-11
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2011-06-20
    相关资源
    最近更新 更多