Jqgrid. onSelectRow - Grab field id and pass url

Asked

Viewed 563 times

0

Oops, I have the following code:

// jqGrid //
      $grid->('onSelectRow', "fnHistoricoPessoa");
// fim jqGrid//

// função para onSelectRow//

function fnHistoricoPessoa(){

var kwGrid = $("#kwGrid").jqGrid('getGridParam', 'selrow');

if(kwGrid != null)
{
    var ret = $("#kwGrid").jqGrid('getRowData',kwGrid);

    $("#grid_historico").setGridParam({url:"/admin/pessoas/listagem_historico.json?id_familia=1",page:1});
    $("#grid_historico").trigger("reloadGrid");


}

} 

With this code I do in jqGrid the option when selecting a line, it fill another grid with the information I want and are: id_familia = 1 only that this 1, I put manual only test the grid, ie it searches in the database the id_familia = 1 and plays on the screen, but I don’t want on every screen to always be the id_familia = 1, I want you to be the id_familia = id da familia que o usuario está buscando.

How do I recover the id the user is searching for?

  • this is a url that has the id of any registered guy: http://localhost:8080/admin/people/members/3984 id_familia = 3984;

  • You will need to assign the value of an input to a variable and pass this variable through the URL.

  • i tried it like this: var kwGrid = $("#kwGrid"). jqGrid('getGridParam', 'selrow'); var Ret = $("#kwGrid"). jqGrid('getRowData',kwGrid); $("#grid_historico"). setGridParam({url:"/admin/people/list_historico.json?id_familia="Ret['id_familia']",page :1}); is something like this that you refer to?

  • It would be something like: var grid = $("#kwGrid"); var columnInfo = grid.jqGrid('getGridParam', 'selrow'); var ret = grid.jqGrid('getRowData', columnInfo); $("#grid_historico").jqGrid('setGridParam', {url: '/admin/pessoas/listagem_historico.json?id_familia=' + ret['id_familia'], page:1});

  • Oops, man I tested it here, but it does not return me anything on the grid. I gave an Alert to test in Ret['id_familia'] and it brings the right id.

  • So what you can do is keep it all in one String and make a alert with her. If the String appear the way it is expected, send by setGridParam.

  • Thanks for your help. I answered my question (:

Show 2 more comments

1 answer

1


I managed doing so with the help from here:

function fnHistoricoPessoa(){

var kwGrid = $("#kwGrid").jqGrid('getGridParam', 'selrow');

if(kwGrid != null)
{
    var ret = $("#kwGrid").jqGrid('getRowData',kwGrid);

    $("#grid_historico").setGridParam({url:"/admin/pessoas/listagem_historico.json?id_familia=" + ret['id_familia'], page:1});
    $("#grid_historico").trigger("reloadGrid");


}

}

Browser other questions tagged

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