將列設(shè)為復(fù)選框
我用數(shù)據(jù)庫(kù)請(qǐng)求加載網(wǎng)格(在PHP中使用CodeIgniter abd jqgrid helper)。我沒(méi)有任何問(wèn)題可以顯示帶有我的數(shù)據(jù)的漂亮網(wǎng)格。我想顯示一個(gè)帶有復(fù)選框的新列,以選擇一個(gè)或幾行。加載后無(wú)法添加新列。因此,我嘗試這樣做:-在創(chuàng)建網(wǎng)格時(shí)添加了列,-在創(chuàng)建時(shí),我添加了帶有函數(shù)的'loadComplete'選項(xiàng),-在播放時(shí),函數(shù)被執(zhí)行。這里是 :function ajoutCheckBox() { var grille = $("#users_grid"); // Construire les checkbox dans la colonne D grille.setColProp('Dest', {editable: true}); grille.setColProp('Dest', {edittype: 'checkbox'}); grille.setColProp('Dest', {editoptions: { value: "True:False" }}); grille.setColProp('Dest', {formatter: "checkbox"}); grille.setColProp('Dest', {formatoptions: { disabled: true}}); // Insérer la valeur false dans toutes les lignes de la colonne D var index = grille.jqGrid('getGridParam', '_index'); for(i in index) { grille.jqGrid('setCell', i, 'Dest', 'False', {}); }}如您所見(jiàn),gris稱(chēng)為“ #users_grid”,列名為“ Dest”。我的問(wèn)題:沒(méi)有附加內(nèi)容...謝謝您的幫助 !XB編輯:我發(fā)現(xiàn)以下解決方案:復(fù)選框列添加在colModel語(yǔ)句中,為了初始化該值并激活復(fù)選框(在創(chuàng)建!時(shí)將其禁用),我使用了"loadComplete"回調(diào)函數(shù)。代碼很簡(jiǎn)單,但我很難找到...網(wǎng)格創(chuàng)建:loadComplete: function() { ajoutCheckBox() },colModel:[.... {"name":"Env","index":"Env","width":30,"hidden":false,"align":"left","edittype":"checkbox","formatter":"checkbox","formatoptions":"{ disabled: false}","editable":true,"editoptions":{"editoptions":"{ value: \"True:False\", defaultValue: \"False\" }}","size":10}}, ....]回調(diào)函數(shù):function ajoutCheckBox() { var grille = $("#users_grid"); var index = grille.jqGrid('getGridParam', '_index'); for(i in index) { // Pour toutes les lignes du tableau grille.jqGrid('setCell', i, 'Env', 'False'); $('#'+i).find("input:checkbox").removeAttr('disabled'); }}它似乎沒(méi)有被優(yōu)化,但是可以工作!
查看完整描述