如何删除jqGrid的行 [英] How to delete row in jqgrid

查看:130
本文介绍了如何删除jqGrid的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的jqGrid的我有一个图标,当我点击它,我必须调用一个AJAX的功能删除我的数据库数据。

in my jqgrid i have an icon and when i click on it I have to call a ajax's function to delete data in my db.

这是在code:

    function loadnotespese(){
     $("#clienti-navgrid").jqGrid( {    
            ....
            colNames:['Tipo spesa','Importo','Unita di misura','Descrizione',''],                 
            colModel:[
                    {name:'category', index:'category', width:'20', sortable:false},  
                    {name:'value', index:'value', width:'10', sortable:false}, 
                    {name:'um', index:'um', width:'5', sortable:false},  
                    {name:'note', index:'note', width:'30', sortable:false},
                    {name:'links', index:'links', width:'5', sortable:false, align:'center', formatter: currencyFmatter, 
                        cellattr: function (rowId, tv, rawObject, cm, rdata) {
                            return ' onClick="deleteNote(' + rowId + ')"';
                        }
                    },
            ],
           ....
        });//jqGrid
}

下面的2个功能:

function currencyFmatter(cellvalue, options, rowObject) {
    var cellValue = rowObject.id;
    return "<img title= 'Elimina' src='/images/delete-icon.png' />";
}


function deleteNote(value){
    var params = {};
    params['idProgetto'] = value;
    $.ajax({
        url: '/project/deletenota.do',
        type: 'GET',
        dataType: 'json',
        data: params,
        success: function(response){
            if (response != "error"){
                $("#clienti-navgrid").trigger("reloadGrid", [{current: true}]);
                dialogNotice("Nota spesa inserita<br/> ", 300, 150);
            }
            else 
                dialogNotice("E' avvenuto un errore nell'inserimento della nota spesa<br/> ", 300, 150);
            }
    });
}

是正确的调用deleteNote()这样吗?还是我错了什么?因为没有任何反应。

is it correct call deleteNote() like this? or i wrong something? because nothing happens.

感谢

推荐答案

如果你想有每行一个删除按钮,你可以通过

If you want to have a delete button per row you could add it via

    {name : 'actions', index: 'actions', formatter:'actions',
    formatoptions: {
    keys: true,
    editbutton: false,
    delOptions: { url: '/controller/deleteRecordAction' }
    }},

您会指定的地方上面的URL来处理删除操作自己的控制器动作。

You would specify your own controller action in place of the above url to handle the delete action.

下面是一个工作示例 http://jsfiddle.net/dumbguy5689/9ueDL/6/

Here is a working example http://jsfiddle.net/dumbguy5689/9ueDL/6/

这篇关于如何删除jqGrid的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆