如何使用Array String方法DELETE删除DB?

时间:2014-06-17 13:48:35

标签: javascript jquery sql extjs

我尝试使用下面的ext.js脚本从我的数据库中删除数据: 当我点击图标"删除"它似乎在浏览器上工作。但当我点击其他工具栏时,点击浏览器的某个位置。它在行网格上重新加载了我的相同数据。我真的不知道我只删除了数组,但没有通过发送错误的服务器或方法删除实际的数据库。我不知道。我尝试使用不同的方法删除它,但同样的问题回来了。

任何人都可以帮助我吗?我是ext.javascript或ext.Ajax ......等新手。

代码:

var userHistoryGrid = Ext.create('Ext.grid.Panel', {
    width: 880,
    height: 450, //autoHeight: true, collapsible: false, title: 'Employee\'s Request History', icon: 'images/newtodo1.png', store: userHistoryStore, multiSelect: false, columnLines: false, enableColumnHide: false, enableColumnMove: false, enableColumnResize: false, selType: 'rowmodel',

    viewConfig: {
        emptyText: 'No prior requests',
        stripeRows: false,
        enableTextSelection: true,

        getRowClass: function (record) {
            return record.get('Status') == 'Approved' ? 'normal-row' : 'hilite-row';
        }
    },

    items: [{
        icon: 'images/delete.png',
        tooltip: 'Delete Request',
        handler: function (grid, rowIndex, colIndex) {
            record = grid.getStore().getAt(rowIndex);
            cellvalue = record.get('Delete');

            if (cellvalue != 'Delete') {
                Ext.MessageBox.confirm(
                    'Confirm Deletion',
                    'Delete this request?',

                function (btn) {
                    if (btn == 'yes') {

                        cellvalue = record.get('EventID');

                        Ext.Ajax.request({
                            url: 'delUserHistoryGrid.asp',
                            async: false,
                            method: 'DELETE',
                            params: {
                                id: userHistoryStore
                            },
                            timeout: 30000,
                            success: function (result) {
                                userHistoryStore.reload();
                                userinfoStore.reload();
                            }
                        });

                        //delete userHistoryStore[rowIndex];
                        userHistoryStore.removeAt(rowIndex);
                        //eventStore.destroy(rowIndex);
                        //userHistoryStore.destroy(rowIndex);
                        //record.EventID.removeAt(grid);
                        userinfoStore.reload();
                    } else {
                        rowEditing.cancelEdit();
                    }
                });
            }
        }
    },

1 个答案:

答案 0 :(得分:0)

一些提示可帮助您查明问题:

  1. 请勿在ajax调用后从商店中删除记录。只有这样才能做到。在成功回调中移动userHistoryStore.removeAt(rowIndex);。 我认为async: false实际上并不存在。所以你的ajax调用会立即返回。您应该在回调中继续执行流程。

  2. 添加failure回调并检查(断点或记录)您获得的响应。您还应该检查success案例中的响应,因为可能还有一些感兴趣的消息。取决于服务。

  3. 使用您的浏览器开发工具并检查网络。您应首先验证ajax调用是否已成功执行,然后您才会收到有效的回复。检查响应代码。如果它不是在200s,这是一个错误。一旦看到您收到的响应代码,就可以更多地搜索网页。

  4. 在不了解您的服务或应用程序的情况下,我认为将id param传递给整个商店可能是错误的。你不应该通过cellvalue吗?