0

In my ruby on rails application, I have the jquery grid as below. Based on the projectId, data should display on grid. But its not working like that. I observed that url is not getting changed on basis of the projectId.

function editTeam_details(projectId)
{
    $("#grdProjectIdentification").jqGrid({

            url:'/project_identification_team?project_id='+projectId,

            colNames: ["Sr.No","Team Leader"],

            colModel: [
            {
                name: "Sr No",
                index: "Sr No",
                width: 15,
                align: "left",
                sortable:true
            },
            {
                name: "Team Leader",
                index: "Team Leader",
                width: 35,
                align: "left",
                sortable:false
            }],
    width: 800,
            height: 100,
            // Paging
            paging : true,
            toppager: true,
            loadonce : false,
            rowNum:20,
            rowList:[20,40,60],
            viewrecords: true,  
            pager: '#pagerProjectIdentification', 
            datatype: 'json',
            sortorder: "desc",
            multiselect: false,
            caption: "1. Project Identification"
        }).jqGrid("navGrid", "#pagerProjectIdentification", {
            edit: true,
            add: true,
            del: true,
            search: true,
            refresh: true
        },
        {}, // settings for edit
        {},
        {}, // settings for del
        {}, // settings for delete
        {
            sopt: ["cn"]
        } // Search options. Some options can be set on column level

        )
}
Vish
  • 89
  • 1
  • 3
  • 13

2 Answers2

0

You should try to replace

url:'/project_identification_team?project_id='+projectId

to

url: '/project_identification_team',
postData: {
    project_id: function () {
        return projectId;
    }
}

In the case the value of project_id parameter of the URL will be evaluated by call of the corresponding function on every request to the server. See the answer for more details.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

Thanks for you reply, Oleg.

I tried the below and it worked.

$("#grdProjectIdentification").GridUnload(); ajaxGridOptions: {cache: false}

Vish
  • 89
  • 1
  • 3
  • 13
  • The second part of the code (`ajaxGridOptions: {cache: false}`) have no sense. If the usage of `$("#grdProjectIdentification").GridUnload()` solves your problem that you calls `editTeam_details` **more as once**. The code inside of `editTeam_details` **creates** the grid. You should create grid once for example during the initialization of the page. If you need refresh the grid *content* with another parameter you need call `$("#grdProjectIdentification").trigger("reloadGrid")` instead. Before reloading you can change the value used in `postData` or change `url` using `setGridParam`. – Oleg Oct 04 '12 at 16:10