DataTable with dropdown Column

后端 未结 4 1169
不思量自难忘°
不思量自难忘° 2020-12-06 07:00

I need to make dropdown as column in DataTable jQuery it is lookinng like as below right now

And I want it like the below image

and the code which I use is

4条回答
  •  佛祖请我去吃肉
    2020-12-06 07:34

    Another way would be to use the render method:

            "render": function(d,t,r){
                var $select = $("", {
                    "id": r[0]+"start",
                    "value": d
                });
                $.each(times, function(k,v){
                    var $option = $("", {
                        "text": v,
                        "value": v
                    });
                    if(d === v){
                        $option.attr("selected", "selected")
                    }
                    $select.append($option);
                });
                return $select.prop("outerHTML");
            }
    

    Working example.

提交回复
热议问题