EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: pedroc on March 18, 2015, 02:17:08 PM



Title: set class selected to multiselect
Post by: pedroc on March 18, 2015, 02:17:08 PM
I'm using a multiline select from an edit form, put the items that once were inserted in the same way I reload to display the items, now I need to put the class selected these items. how to do?


Title: Re: set class selected to multiselect
Post by: jarry on March 18, 2015, 03:23:34 PM
What editor are you using ? How do you reload your form data ? Please describe your question in more detail.


Title: Re: set class selected to multiselect
Post by: pedroc on March 19, 2015, 05:03:10 AM
I am using a form where I have the multiselect the problem is, how to load it already inserted at a given time?

<input id="gd05" class="easyui-combobox" required style="width:68%" data-options="
                valueField:'id_area',
                textField:'area',
                onSelect: function(rec){
                    //$('#box1').combobox('clear');
                    var url = '<?= base_url() ?>index.php/c_grpodistrib/get_trab/'+rec.area;
                    $('#box1').combobox('reload', url);
                }">
        <select id="box1" name="trabajadores[]" class="easyui-combobox" editable='false' required style="width: 100%; height: 50px" data-options="
            textField:'nombre',
            valueField:'id',
            multiple:true,
            multiline:true">
        </select>

this is what I want to do in the Edit button onClick
$.ajax({
            type: "POST",
            cache: false,
            url: 'c_grpodistrib/get_trab_del_grpo/'+row.id_grpodistrib,
            dataType: 'json',
            success: function(dato) {
                var result = [];
                $.each(dato, function(idx, obj) {
                    result[idx]=obj.nombre;
                });
                $('#box1').combobox('setValues', result);
                $('#box1').combobox('reload', 'c_grpodistrib/get_trab_del_grpo/'+row.id_grpodistrib);
            },
            error : function(xhr, status) {
                alert('Esto nunca debe suceder');
            }
        });


Title: Re: set class selected to multiselect
Post by: jarry on March 19, 2015, 07:35:27 AM
You can call 'setValues' method to select the special items, or set the 'selected' property to true for those items you want to select. The following item will be selected since it has the 'selected' property set to true.
Code:
[{
"id":3,
"text":"Ruby",
"selected":true
}]