0
votes

I am using jQuery Data tables.

In one of the columns in a data table I want to display data in a select box with the actual value of that cell as the selected value.

Is there any way to hook a lookup table to the column such that each cell of that column is hooked with a lookup table?

If the user wants to update value of that particular cell can the user can select any of the values from the select box?

1
That is indeed possible, what have you tried? - annoyingmouse
using the render option for that column - Bindrid
@annoyingmouse Yes i have tried the same way Bindrid did. - Darshit Jain

1 Answers

0
votes

something like this? http://jsbin.com/solipe/edit?html,js,output

$(document).ready(function() {

    // create fake column to put in selectbox
    for(var i = 0; i < dataStore.data.length; ++i){
       var b = Math.floor((Math.random() * 10) + 1);
       dataStore.data[i].groupId = b;
    }

    $('#example').DataTable( {
        "data": dataStore.data,
        "columns": [
            { "data": "name" },
            { "data": "groupId"},
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }], 
        dom: 'Bfrtip',
        columnDefs:[{targets:[1], 
            render:function(a,b,c,d){
                var str = "";
                for(var j = 1; j < 11; ++j){
                    str += "<option " +(j == a? " selected ":"")+"  value='" + j + "'>"  + j + "</option>";
                }
                str = "<select>" + str + "</select>";
                return str;
           }}]

    } );
});