Author Topic: example of using checkboxdropdownlist  (Read 3785 times)

stoodin

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
example of using checkboxdropdownlist
« on: April 04, 2014, 10:33:00 pm »
Hi guys,
Can someone show me how to use the checkboxdropdownlist,especially https://github.com/wenzhixin/multiple-select
I am trying to create a custom editor but it doesn't work:
    var selectEditor = function (ui) {
            var dataIndx = ui.dataIndx;
            var options = ['', 'FName1 LName1','FName2 LName2','FName3 LName3'],
                str="";
            for (var i = 0; i < options.length; i++) {
                var opt = options;
                str += "<option>" + opt + "</option>";
            }
            var $sel = $('<select id="example" name="' + dataIndx + '" multiple="multiple" >' + str + "</select>");
            $sel.multipleSelect();
        };

Thanks in advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: example of using checkboxdropdownlist
« Reply #1 on: April 04, 2014, 10:46:12 pm »
you are almost there

2 corrections:

 var opt = options[ i ];

$sel.appendTo( ui.$cell )

Example of custom editor:

http://paramquery.com/pro/demos/editing_custom

stoodin

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
Re: example of using checkboxdropdownlist
« Reply #2 on: April 04, 2014, 11:23:29 pm »
Thanks a lot.
Still not working. It shows just standard HTML dropdown multiselect. But I want to see http://wenzhixin.net.cn/p/multiple-select/

Here is my new version of the editor:
    var selectEditor = function (ui) {
        var options = ['', 'FName1 LName1','FName2 LName2','FName3 LName3'],
            str="";
        for (var i = 0; i < options.length; i++) {
            str += "<option>" + options + "</option>";
        }
       
        var $sel = $('<select id="example" name="'+dataIndx+'" multiple="multiple" >'+str+"</select>")
            .appendTo(ui.$cell)
            .multipleSelect();       
    };

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: example of using checkboxdropdownlist
« Reply #3 on: April 04, 2014, 11:56:34 pm »
you can try to wrap multiselect in a setTimeout

Code: [Select]
window.setTimeout(function(){
  $sel.multipleSelect();   
}, 0);

stoodin

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
Re: example of using checkboxdropdownlist
« Reply #4 on: April 05, 2014, 12:07:03 am »
hmm,
Works partially now: (Doesn't show the options values, just an empty "Select All" and one empty checkbox.
It works fine without grid though...

    var selectEditor = function (ui) {
        var $cell = ui.$cell,
            rowData = ui.rowData,
            dataIndx = ui.dataIndx,
            cls = ui.cls,
            dc = $.trim(rowData[dataIndx]);
        var options = ['', 'FName1 LName1','FName2 LName2','FName3 LName3'],
            str="";
        for (var i = 0; i < options.length; i++) {
            str += '<option value="' + i + '">' + options + '</option>';
        }
        var $sel = $('<select id="example" multiple="multiple" name="' + dataIndx + '" >'+str+"</select>")
            .appendTo($cell)
            .val(dc)
            .multipleSelect({
                width: ui.column.width
        });       
    };