2

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?? enter image description here

leora
  • 188,729
  • 360
  • 878
  • 1,366

2 Answers2

3

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

  • The problem here is how can I get the values salved before and show it checked when my form opens in edit action?? – Zanoldor Mar 15 '20 at 20:05
1

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

enter image description here

jQuery("#grid_id").setGridParam({multiselect:true}).showCol('cb');
John K.
  • 5,426
  • 1
  • 21
  • 20
  • 1
    i dont want multiselect rows. I want an editor in a cell that will allow me to select multiple entries to represent a list. – leora Feb 02 '11 at 15:54
  • 2
    Check out... http://stackoverflow.com/questions/2825000/jqgrid-multi-checkbox-custom-edittype-solution ... it looks like "gsiler" has created a "multi-checkbox form element" and used it as a custom edit-type. – John K. Feb 02 '11 at 15:59