1. 程式人生 > >easyUI(二) -- 怎麼實現多選並取得選中項指定資料

easyUI(二) -- 怎麼實現多選並取得選中項指定資料

在easyUI中實現多選是很簡單的一件事情 , 在你的表格中加一個

<th field="ck" checkbox="true"></th>

, 就會出現checkBox ,
那麼怎麼取出它的 ID 呢

function selectId(){
    var ids = new Array();
    for(var i=0; i<rows.length; i++){  
        ids[i] = (rows[i].itemid);       
        alert(ids[i]);
    }  
}

接下來定義一個按鈕呼叫這個方法就可以實現

<a href="#" onclick="return selectId()">選中項</a>

如果你想取得其他資料的話 , 同樣的定義陣列取出即可