将新数据加载到jqgrid无效

时间:2012-10-04 14:41:47

标签: ruby-on-rails jqgrid

在我的ruby on rails应用程序中,我有如下的jquery网格。基于projectId,数据应显示在网格上。但它不像那样工作。我观察到url没有根据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

        )
}

2 个答案:

答案 0 :(得分:0)

您应该尝试替换

url:'/project_identification_team?project_id='+projectId

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

在通过对服务器的每个请求调用相应函数来评估URL的project_id参数的值的情况下。有关详细信息,请参阅the answer

答案 1 :(得分:0)

谢谢你的回复,奥列格。

我尝试了下面的方法并且有效。

$( “#grdProjectIdentification”)GridUnload(); ajaxGridOptions:{cache:false}