does jqgrid support a multiple checkbox list for editing

我是研究僧i 提交于 2020-01-04 11:38:22

问题


I am playing around with jqgrid and I want to edit a row entry. One of the cells is a list so I want some sort of multiselect editor inside a cell. i dont see support for a cell edit where i can choose multiple entries from a list. select (either multiselect list or even better a dropdown of checkboxes)

is there any support for something like this??


回答1:


see: http://www.secondpersonplural.ca/jqgriddocs/_2eb0fb79d.htm

jQuery("#grid_id").setGridParam({multiselect:true}).showCol('cb');



回答2:


Working example:

{ name: "Id_ListaMultiple", index:"Id_ListaMultiple",editable:true,edittype:"custom",editoptions:{custom_element:multiCheckElem, custom_value:multiCheckVal,list:"2:Reposición;1:Solicitud Inicial"}},

function multiCheckElem(values, optio) {
    var id = optio.id;
    var ctl = '<div id="'+ id + '" class="checklist">';
    var ckboxAry = optio.list.split(';');
    var aValues = [];
    if (values && values.length)
    {
        aValues = values.split(",");
    }
    for (var i = 0; i < ckboxAry.length; i++)
    {
        var item = ckboxAry[i].split(':');
        ctl += '<input type="checkbox" ';

        if (aValues.indexOf(item[0]) != -1)
        {
            ctl += 'checked="checked" ';
        }
        ctl += 'value="' + item[0] + '"> ' + item[1] + '</input><br/>';
    }
    return ctl + '</div>';
}

function multiCheckVal(elem, action, val) {
    var items = '';
    if (action == 'get') // submitted
    {

        $("input[type=checkbox]:checked", elem).each(function (i, e)
        {
            if (items) items += ","
            items += e.value;
        });

    }
    else // launched
    {

    }
    return items;
}

Regards Henry



来源:https://stackoverflow.com/questions/4876433/does-jqgrid-support-a-multiple-checkbox-list-for-editing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!