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;
            }
        }
        
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM