选定的行在jqgrid中不突出显示 [英] Selected row not highlighted in jqgrid

查看:141
本文介绍了选定的行在jqgrid中不突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了行选择功能。它没有突出显示所选行(有时突出显示有时突出显示其他行),也没有按照我所写的方式显示图标。以下是代码
multiselect:true,
iconSet:fontAwesome,
datatype:json,
loadonce:true,
rowNum:10,
rowList:[10,20,30],
toppager:true,
pager:'#prowed1',
sortname:'id',
viewrecords:true,
sortorder:asc,
editurl:editGrid.html,
onSelectRow:function(rowId){
var rowId = jQuery(#list1 ).jqGrid('getGridParam',
'selarrrow');
if(rowId.length> 1){
$(#list1_iledit)。addClass('ui-state-disabled');


$ b $ $ $ $ $ $ $ $#list1)。 jqGrid(
navGrid,
#prowed1,
{
cloneToTop:true,
格式化程序:checkboxFontAwesome4,
addicon:fa fa-plus,
add:true,
delicon:fa fa-trash,
del:true,
searchicon:fa fa-search,
搜索:true,
refreshicon:fa fa-refresh,
refresh:true,
editicon:fa fa-edit,
编辑:true,
saveicon:'fa fa-floppy-o',
save:true,

},`{//编辑选项
afterSubmit:function(){
location.reload(true);
},
beforeShowForm:function(form){
$(td .navButton navButton-ltr)。hide();
},
closeAfterEdit:true
},
{//添加选项
beforeShowForm:function(form){
$(#buName) .removeAttr( 只读);
},
closeAfterAdd:true,
clearAfterAdd:true
},
{// del选项
serializeDelData:function(postdata){
返回{
'buName':$('#list1')。jqGrid('getCell',
postdata.id,'buName'),
'oper':'del'
}
}
}

);`$(#list1)。jqGrid('inlineNav',#prowed1,{
/ / cloneToTop:true,
// iconSet:fontAwesome,
add:false,
编辑:true,
editicon:'fa fa-pencil-square-o',
save:true,
saveicon:'fa fa-floppy-o',
editParams:{
aftersavefunc:function(id){
jQuery('#list1 ').jqGrid('setSelection',id,false);
},
},
});`


解决方案

您应该提供重现问题的演示。突出显示的问题最多的原因是:错误的输入数据或错误 colModel 。 jqGrid的每一行都有id属性(rowid),它应该是输入数据的一部分:请参阅这里。该id值必须是唯一的。如果你有id重复,那么你可能会遇到选择/突出显示行的问题。



如果你填充数据库中的数据,你可以使用表中的native id数据库来构建独特的rowid。数据库表不允许标识符重复。

为了能够编辑数据库中的数据,您需要标识编辑的数据。这种独特的价值可以用作rowid。如果您通过JOIN从多个表中填充网格,则可以使用组合ID 。例如,如果使用两个表User和Location中的数据填充网格,则paar(user_id,location_id)是唯一的。如果user_id和location_id都是数字,那么可以使用 user_id +_+ location_id 作为rowid。该值将在编辑期间发送到服务器,您将获得完整的信息来查找表中的数据,这些数据需要修改。


I have written the function for row selection.It is not highlighting the selected row(sometimes highlighting sometimes other row highlighted) and not displaying the icons the way I have written it. following is the code multiselect : true, iconSet: "fontAwesome", datatype : "json", loadonce : true, rowNum : 10, rowList : [ 10, 20, 30 ], toppager:true, pager : '#prowed1', sortname : 'id', viewrecords : true, sortorder : "asc", editurl : "editGrid.html", onSelectRow : function(rowId) { var rowId = jQuery("#list1").jqGrid('getGridParam', 'selarrrow'); if (rowId.length > 1) { $("#list1_iledit").addClass('ui-state-disabled'); } },

$("#list1").jqGrid(
            "navGrid",
            "#prowed1",
            {
                cloneToTop:true,
                formatter : "checkboxFontAwesome4",
                 addicon:"fa fa-plus ",
                add : true,
                delicon:"fa fa-trash",
                del : true,
                searchicon:"fa fa-search",
                search : true,
                refreshicon:"fa fa-refresh",
                refresh : true,
                editicon:"fa fa-edit ",
                edit : true,
                saveicon : 'fa fa-floppy-o',
                save : true,

            },`{ // edit options
                afterSubmit : function() {
                    location.reload(true);
                },
                beforeShowForm : function(form) {
                    $("td .navButton navButton-ltr").hide();
                },
                closeAfterEdit : true
            },
            { // add options
                beforeShowForm : function(form) {
                    $("#buName").removeAttr("readonly");
                },
                closeAfterAdd : true,
                clearAfterAdd : true
            },
            { // del options
                serializeDelData : function(postdata) {
                    return {
                        'buName' : $('#list1').jqGrid('getCell',
                                postdata.id, 'buName'),
                        'oper' : 'del'
                    }
                }
            }

    );` $("#list1").jqGrid('inlineNav', "#prowed1", {
        //cloneToTop:true,
        //iconSet: "fontAwesome",
        add : false,
        edit : true,
        editicon : 'fa fa-pencil-square-o',
        save : true,
        saveicon : 'fa fa-floppy-o',
        editParams : {
            aftersavefunc : function(id) {
                jQuery('#list1').jqGrid('setSelection', id, false);
            },
        },
    });`

解决方案

You should provide the demo, which reproduce the problem. The reason of the most problems with highlighted: wrong input data or wrong colModel. Every row of jqGrid have always id attribute (rowid), which should be part of input data: see here. The id value must be unique. If you have id duplicates then you could problems with selection/highlighting of rows.

If you fill the data from the database than you can use native ids from the tables of the database to build unique rowids. Database tables don't allow id duplicates too.

To be able to edit the data in the database you will need to identify the edited data. Such unique value could be used as the rowid. If you fill the grid by JOIN from multiple tables, than composed id could be used. For example, if you fill the the grid with the data from two tables User and Location then the paar (user_id, location_id) are unique. If both user_id and location_id are numbers, then you can use user_id + "_" + location_id as rowid. The value will be sent to the server during editing and you will have full information to find the data in the tables, which need be modified.

这篇关于选定的行在jqgrid中不突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆