Jqgrid calling a function by clicking on a cell passing the line id

Asked

Viewed 299 times

0

Good morning, I need 2 help from you. First time with Jqgrid.

1- I need to add another column on the grid with an image that will call a modal by passing the value of the line ID.

2- I also need to place a function that will open the editing screen with double click on. Already I can do with a click on the line, but it does not fit me, it needs to be with the double click.

$(function () {
    var grid = $("#jqGrid").jqGrid({
        //url: '@Url.Action("Lista","Perfil", new { Area = "Gerenciamento" })',
        url:'/Gerenciamento/Perfil/ListaPeloDAO',
        mtype: 'GET',
        datatype: 'json',
        colModel: [
            { label: 'Id', name: 'id', width: 50 },
            { label: 'Descricao', name: 'descricao', width:380 }, 
        ],
        loadonce: true,
        pager: '#jqGridPager',
        rowNum: 10,
        rowList: [10, 20, 30, 50],
        viewrecords: true,
        height: 250
    });
    $("#jqGrid").jqGrid('navGrid', 'jqGridPager', { edit: false, add: false, del: false })
    jQuery("#jqGrid").click(function () {
        //Pega Id linha selecinada 
        var PegaIdDaGRid = grid.getGridParam("selrow");
        //Chama a tela do Editar passando o ID
        window.location = '/Gerenciamento/Perfil/Cadastro/' + PegaIdDaGRid;
    });
});
  • what you have tried?

  • Hello Paul. Actually I already got it. See:

  • jQuery("#jqGrid"). dblclick(Function() { //Grab Id selected line var Pegaiddagrid = grid.getGridParam("selrow"); //Calls the Edit screen by passing the ID window.Location = '/Management/External/User/Registration/' + Pegaiddagrid; }); Function addressRecourse(cellValue, options, rowdata, action) { Return "<a href='/Management/External user/Profile/" + options.rowId + "'>+ Profile</a>"; }

  • Thank you. Next time

1 answer

0


For knowledge, follows how the result was, everything working perfectly, with double click and image:

$(function () {

    var grid = $("#jqGrid").jqGrid({
        //url: '@Url.Action("Lista","Recurso", new { Area = "Gerenciamento" })',
        url:'/Gerenciamento/UsuarioExterno/Listar',
        mtype: 'GET',
        datatype: 'json',
        colModel: [
            { label: 'ID', name: 'id',width:50 },
            { label: 'codigo', name: 'codigoRepresentante', width:80 },
            { label: 'Nome', name: 'nome' , width:200 },           
            { label: 'Email', name: 'email', width:80  },           
            { label: 'Cpf', name: 'cpf', width:80  },           
            {
                label: 'Data_Inclusao', name: 'data_inclusao', formatter: 'date', width:100, 
                formatoptions: { srcformat: 'd/m/y', newformat: 'd/m/y H:s' }
            },

            { name: 'Perfil', index: 'recursos', width: 80, align: "center", editable: true, formatter: adicionarRecurso },  
            { name: 'Exceção', index: 'recursos', width: 80, align: "center", editable: true, formatter: adicionarExcecao },  
        ],

        loadonce: true,
        pager: '#jqGridPager',
        rowNum: 10,
        rowList: [10, 20, 30, 50],
        viewrecords: true,
        height: 250

    });
    $("#jqGrid").jqGrid('navGrid', 'jqGridPager', { edit: false, add: false, del: false })

    jQuery("#jqGrid").dblclick(function () {

        //Pega Id linha selecinada 
        var PegaIdDaGRid = grid.getGridParam("selrow");
        //Chama a tela do Editar passando o ID
        window.location = '/Gerenciamento/UsuarioExterno/Cadastro/' + PegaIdDaGRid;

    });

    function adicionarRecurso(cellValue, options, rowdata, action) {
        return "<a href='/Gerenciamento/UsuarioExterno/Perfil/" + options.rowId + "'>+ Perfil</a>";        
    }  

    function adicionarExcecao(cellValue, options, rowdata, action) {
        return "<a href='/Gerenciamento/UsuarioExterno/Excecao/" + options.rowId + "'>+ Exceção</a>";        
    }  
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.