JqG​​rid中的tr Id始终为0

时间:2016-04-12 05:08:09

标签: javascript jquery jqgrid

我用JqGrid写了一个表,但我发现表的每一行属性都是“tr id = 0”以下是我的代码和截图。是什么导致了这个错误任何帮助将不胜感激。

jQuery(grid_selector).jqGrid({
        datatype: "json",
        url:"getAllUserInfo.do",
        mtype: 'POST',
        height: 250,
        colNames: ['Operation', 'userID', 'UserName', 'FullName', 'Department', 'Role', 'Telephone', 'MobilePhone', 'Mail', 'Status'],

        colModel: [
            {name: 'myac', index: '', width: 80, fixed: true, sortable: false, resize: false,search:false,
                formatter: 'actions',
                formatoptions: {
                    keys: true,
                    delOptions: {recreateForm: true, beforeShowForm: beforeDeleteCallback},
                    onSuccess:function(respone){
                        var msg=respone.responseText;
                        if(msg=='success')
                            return true;
                        else
                          {
                        	 alert(msg);
                             return [false,msg];
                            }
                        },
                     editOptions:{recreateForm: true, beforeShowForm:beforeEditCallback,}
                }
            },
        	
        	{name: 'userID', index: 'userID', width: 60, sorttype: "int", editable:false, sortable:false, search:false, align:'center' },
            {name: 'userName', index: 'userName', width: 100, editable: true, sorttype: "text",searchoptions:{sopt:['eq','ne','in','ni']},editrules:{required:true},align:'center'},
            {name: 'fullName', index: 'fullName', width: 100, editable: true, sorttype: "text", searchoptions:{sopt:['eq','ne','in','ni']},editoptions: {size: "20", maxlength: "30"}},
            {name: 'department', index: 'department', width: 100, editable: true, sorttype: "text", searchoptions:{sopt:['eq','ne','in','ni']},editoptions: {size: "20", maxlength: "30"},editrules:{required:true}},
            {name: 'role', index: 'role', width: 70, editable: true, sorttype: "text",searchoptions:{sopt:['eq','ne','in','ni']}, editrules:{required:true}},
            {name: 'telephone', index: 'telephone', width: 70, editable: true, sorttype: "text", searchoptions:{sopt:['eq','ne','in','ni']},editrules:{required:true,number:true}},
            {name: 'mobilePhone', index: 'mobilePhone', width: 150,editable:true, edittype:"text", searchoptions:{sopt:['eq','ne','in','ni']}},
            {name: 'mail', index: 'mail', width: 150,editable:true, edittype:"text", searchoptions:{sopt:['eq','ne','in','ni']}},
            {name: 'status', index: 'status', width: 60, editable:true, edittype:"text", searchoptions:{sopt:['eq','ne']}}
            
        ],
        viewrecords: true,
        rowNum: 10,
        rowList: [10, 20, 30],
        pager: pager_selector,
        altRows: true,
        multiselect: true,
        multiboxonly: true,
        onCellSelect:function(rowid, e){        
           
            },
        gridComplete:function (){
         $("#grid-table").closest("div.ui-jqgrid-view")
                 .children("div.ui-jqgrid-titlebar")
                .css("text-align", "center").css("line-height","40px")
                 .children("span.ui-jqgrid-title")
                  .css("float", "none");
        },
        loadComplete: function () {
            var table = this;
            setTimeout(function () {
                var msg= $("#grid-table").getGridParam('userData');
          
                styleCheckbox(table);
                updateActionIcons(table);
                updatePagerIcons(table);
                enableTooltips(table);
            }, 0);
            var re_records = $("#grid-table").getGridParam('records');
        	if(re_records == 0 || re_records == null){
        		if($(".norecords").html() == null){
        			$("#grid-table").parent().append("<div class=\"norecords\">No Records</div>");
        		}
        		$(".norecords").show();
        	}
        	else
            	{
        		$(".norecords").hide();
            	}
        },
        editurl:"userInfoOperate.do",
        caption: "UserList",
        autowidth: true,
       
    });

Img

1 个答案:

答案 0 :(得分:0)

检查行数据是否包含&#34; id&#34;正如名字一样,如下图所示。 JqG​​rid将使用&#34; id&#34;的值行数据中的列作为tr标记的id值,如果它在行数据中有一个id列。 picture