简体   繁体   English

如何在extjs中的ajax中创建新窗口

[英]how to create a new window in ajax in extjs

I know there are othe questions like mine but, the details are important in my case and the details of this question are different from the one in the question already made. 我知道还有其他类似我的问题,但是细节对我来说很重要,这个问题的细节与已经提出的问题有所不同。 however the problem is that I'm trying to build a new window with extjs, starting from a grid already done. 但是问题是我试图从已经完成的网格开始,使用extjs构建一个新窗口。 This new window should contain a grid with al the references to the element selected of the previous grid. 该新窗口应包含一个网格,其中包含对先前网格中所选元素的引用。 So this is my solution, I placed an ajax call inside the first grid. 这就是我的解决方案,我在第一个网格内放置了一个ajax调用。 I made a column to contain the image to be cliccked to get to the second grid. 我创建了一个列,以包含要单击的图像以到达第二个网格。 But it is not working. 但这是行不通的。 When i click on the image it doesn't show nothing? 当我单击图像时,它什么也不显示?

Am I wrong doing the ajax call?Am i wrong passing the json to the page for the store of the grid that should be in the new window? 我在执行ajax调用时出错吗?我将json传递到应该在新窗口中的网格存储页面时是否出错? Any idea? 任何想法? This is the code of my grids: 这是我的网格的代码:

 var grid = Ext.create('Ext.grid.Panel', {
    store: store1,
    stateful: true,
    collapsible: true,
    multiSelect: true,
    stateId: 'stateGrid',
    columns: [
        {
            text     : 'id',
            flex     : 1,
            sortable : true,
            dataIndex: 'id'
        },
        {
            text     : 'buyer_member_id',
            width    : 75,
            sortable : true,
            dataIndex: 'buyer_member_id'
        },
        {
            text     : 'Client Name',
            width    : 200,
            sortable : true,
            dataIndex: 'name'
        },
        {
            xtype : 'actioncolumn',
            width : '5%',
            sortable : false,
            items : [{
                icon : '../static/accept.gif',
                tooltip : 'See Admants',
                handler : function(grid, rowIndex, colIndex){
                    var row = grid.getStore().getAt(rowIndex);
                    buyer_member_id = grid.getSelectionModel.getSelection()[1]
                    Ext.Ajax.defaultHeaders = {
                        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
                    };
                    Ext.Ajax.request({
                        method : "GET",     
                        url: '/mygrid/',
                        params:{
                                buyer_member_id: buyer_member_id,
                        },
                        success : function(response) {
                            var obj = response;
                            try {
                                obj = Ext.decode(response.responseText);
                            } catch (error) {}
                            if (obj) {
                                Ext.create('Ext.window.Window', {
                                title: 'Hello',
                                height: 200,
                                width: 400,
                                layout: 'fit',
                                items: {  // Let's put an empty grid in just to illustrate fit layout
                                xtype: 'grid',
                                border: false,
                                columns: [
                                        {
                                            text     : 'id',
                                            flex     : 1,
                                            sortable : true,
                                            dataIndex: 'id'
                                        },
                                        {
                                            text     : 'name',
                                            width    : 300,
                                            sortable : true,
                                            dataIndex: 'name'
                                        }],                 // One header just for show. There's no data,
                                store: new Ext.data.JsonStore({
                                    // store configs
                                    storeId: 'myStore',
                                    proxy: {
                                        type: 'ajax',
                                        url: '/admants/',
                                        reader: {
                                            type: 'json',
                                        }
                                    },})

                                }}).show();
                            } else {
                            alert("Invalid response")
                            }
                        },
                        failure : function(response) {
                            alert("Data request failed");
                        }
                    }); 
                }
            }]
        }
    ],

The piece of code that follows opens a new window and reads the data for the ajax call. 后面的代码段打开一个新窗口,并读取ajax调用的数据。 STil the "store" is not working but i will post a new question specifically for it. 直到“商店”不起作用,但我将专门针对它发布一个新问题。

{
            xtype : 'actioncolumn',
            width : '5%',
            sortable : false,
            items : [{
                icon : '../static/accept.gif',
                tooltip : 'See Admants',
                handler : function(grid, rowIndex, colIndex){
                    var row = grid.getStore().getAt(rowIndex);
                    //buyer_member_id = grid.getSelectionModel.getSelection()[1]
                     var row = grid.getStore().getAt(rowIndex);
                     var buyer_member_id = row.data.buyer_member_id;
                    Ext.Ajax.defaultHeaders = {
                        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
                    };
                    Ext.Ajax.request({
                        method : "GET",     
                        url: '/admants/?buyer_member_id='+ buyer_member_id,
                        success : function(response) {
                            var obj = response;
                            try {
                                obj = Ext.decode(response.responseText);
                            } catch (error) {}
                            if (obj) {
                                Ext.create('Ext.window.Window', {
                                title: 'Hello',
                                height: 200,
                                width: 400,
                                layout: 'fit',
                                items: {  // Let's put an empty grid in just to illustrate fit layout
                                xtype: 'grid',
                                border: false,
                                columns: [
                                        {
                                            text     : 'id',
                                            flex     : 1,
                                            sortable : true,
                                            dataIndex: 'id'
                                        },
                                        {
                                            text     : 'name',
                                            width    : 300,
                                            sortable : true,
                                            dataIndex: 'name'
                                        }],                 // One header just for show. There's no data,
                                store: new Ext.data.JsonStore({
                                    // store configs
                                    storeId: 'myStore',
                                    proxy: {
                                        type: 'ajax',
                                        url: '/admants/',
                                        reader: {
                                            type: 'json',
                                        }
                                    },})

                                }}).show();
                            } else {
                            alert("Invalid response")
                            }
                        },
                        failure : function(response) {
                            alert("Data request failed");
                        }
                    }); 
                }
            }]
        }
    ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM