开发者

JQGrid select row checkboxclick

I try to receive row id of JQGrid on checkbox click like:

loadComplete : function() {
    jQuery(".jqgrow td input").each(function() {
        jQuery(this).click(function() {
            var grid = $("#list");
            var rowid = grid.jqGrid('getGridParam', 'selrow');
            alert(rowid);
        });
    });
}

But row is not selected - so I always receive a null开发者_如何学运维. What can be the reason? Thanks.


The reason is var rowid = grid.jqGrid('getGridParam', 'selrow'); will only contain rowid if you have already selected a row by clicking on the row before.

If you want an alternative, then you can select the checkbox on onSelectRow instead

onSelectRow: function(id,status){
    var rowData = jQuery(this).getRowData(id); 
    var ch = jQuery(this).find('#'+id+' input[type=checkbox]').attr('checked');
    if(ch) {
        jQuery(this).find('#'+id+' input[type=checkbox]').attr('checked',false);
    } else {
        jQuery(this).find('#'+id+' input[type=checkbox]').attr('checked',true);                       
    }

    rowChecked=1;
    currentrow=id;
}


Why not use the onSelectRow event built in jqGrid?

You can read more about jqGrid events here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜