我用數(shù)據(jù)庫請求加載網(wǎng)格(在PHP中使用CodeIgniter abd jqgrid helper)。我沒有任何問題可以顯示帶有我的數(shù)據(jù)的漂亮網(wǎng)格。我想顯示一個帶有復(fù)選框的新列,以選擇一個或幾行。加載后無法添加新列。因此,我嘗試這樣做:-在創(chuàng)建網(wǎng)格時添加了列,-在創(chuàng)建時,我添加了帶有函數(shù)的'loadComplete'選項,-在播放時,函數(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', {}); }}如您所見,gris稱為“ #users_grid”,列名為“ Dest”。我的問題:沒有附加內(nèi)容...謝謝您的幫助 !XB編輯:我發(fā)現(xiàn)以下解決方案:復(fù)選框列添加在colModel語句中,為了初始化該值并激活復(fù)選框(在創(chuàng)建!時將其禁用),我使用了"loadComplete"回調(diào)函數(shù)。代碼很簡單,但我很難找到...網(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'); }}它似乎沒有被優(yōu)化,但是可以工作!
將列設(shè)為復(fù)選框
九州編程
2019-11-04 10:37:30