jqgrid:如何为特定列设置编辑选项false并更新其值

时间:2012-12-06 07:20:13

标签: jquery asp.net-mvc jqgrid

我有一个内联编辑工作正常的jqgrid,我的要求是我要禁用studentId的编辑选项,我为该studentId列声明了editable:false,但是当我点击保存按钮时我得到了错误.. 。参数字典包含参数'StudentId'的空条目,非参数类型'System.Int32'用于方法.....'

我的jquery

    <script type="text/javascript">
    $(function () {
        var lastsel;

        jQuery("#list").jqGrid({
            url: '/Home/GetStudents/',
            datatype: 'json',

            mtype: 'POST',
            colNames: ['StudentID', 'FirstName', 'LastName', 'Email', 'Actions', ],

            colModel: [
      { name: 'StudentID', sortable: false, key: true,editable:false },
      { name: 'FirstName', key: true },
      { name: 'LastName', sortable: false, key: true },
      { name: 'Email', width: 200, sortable: false, key: true },
      { name: 'act', index: 'act', width: 75, sortable: false, editable: false}],
            cmTemplate: { align: 'center', editable: true },
            pager: '#pager',
            width: 750,
            rowNum: 15,
            rowList: [5, 10, 20, 50],
            sortname: 'StudentID',
            sortorder: "asc",
            viewrecords: true,
            caption: ' My First JQgrid',
            gridview: true,
            width: 850,



            gridComplete: function () {
                var ids = jQuery("#list").jqGrid('getDataIDs');

                for (var i = 0; i < ids.length; i++) {
                    var cl = ids[i];

                    be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=\"jQuery('#list').editRow('" + cl + "');\"  />";
                    se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=\"jQuery('#list').saveRow('" + cl + "');\"  />";
                    ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#list').restoreRow('" + cl + "');\" />";
                    jQuery("#list").jqGrid('setRowData', ids[i], { act: be + se + ce });
                }
            },

1 个答案:

答案 0 :(得分:0)

目前还不清楚等待服务器部分的信息。您可以尝试使用

prmNames: {id: "StudentID"}

它会将当前发送到服务器的id参数重命名为StudentID