easyui datagrid 單選框 效果

columns: [[{
            field: 'oid',
            title: '選擇',
            width: 20,
            formatter: function(value, rowData, rowIndex){
                return '<input type="radio" name="selectRadio" id="selectRadio"' + rowIndex + '    value="' + rowData.oid + '" />';
            }
        }



onLoadSuccess: function(data){
            //加載完畢後獲取所有的checkbox遍歷
            if (data.rows.length > 0) {
                //循環判斷操作爲新增的不能選擇
                for (var i = 0; i < data.rows.length; i++) {
                    //根據operate讓某些行不可選
                    if (data.rows[i].operate == "false") {
                        $("input[type='radio']")[i].disabled = true;
                    }
                }
            }
        },
        onClickRow: function(rowIndex, rowData){
            //加載完畢後獲取所有的checkbox遍歷
            var radio = $("input[type='radio']")[rowIndex].disabled;
            //如果當前的單選框不可選,則不讓其選中
            if (radio!= true) {
                //讓點擊的行單選按鈕選中
                $("input[type='radio']")[rowIndex].checked = true;
            }
            else {
                $("input[type='radio']")[rowIndex].checked = false;
            }

        }


轉載網址:http://blog.csdn.net/fengxing_2/article/details/8856096

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章