how to fill data in textbox inside datatables getting from dropdown during load using jquery

how to fill data in textbox inside datatables getting from dropdown during load using jquery

haivijaykumar1haivijaykumar1 Posts: 2Questions: 1Answers: 0

Hi everyone,
I have a datatable in which I have 2 columns. 1 is a dropdown and 2 is a textbox. I would like to set the all dropdown selected value in text box when loading in all rows.

Answers

  • haivijaykumar1haivijaykumar1 Posts: 2Questions: 1Answers: 0
    edited January 2019

    Please note, the following are 2 columns I have. both are being filled from an ajax call.

    "columns": [
            {
                            "data": "Id", "orderable": true, "name": 'action', 'responsivePriority': 3,
                            "render": function (d, t, r) {
                                var select = $("<select></select>", { "value": d, 'class': 'selected-action' });
                                
                                $.each(actionValues, function (k, v) {
                                    var $option = $("<option></option>", {
                                        "text": v.Name,
                                        "value": v.Id
                                    });
                                    if (d === v.Id) {
                                        $option.attr("selected", "selected")
                                    }
                                   
    
                                    select.append($option);
                                });
                                current_row = this;
                                return select.prop("outerHTML");
                            }
                        },
                        {
                            "data": "Comments",
                            render: function (data, type, row) {                            
                                return '<input class="form-control" id="Comments" name="Comments" maxlength="350" multiline="true" readonly="true" type="text"  value =' + row.Comments + '>';
                                
                            }
                        }
    ]
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @haivijaykumar1 ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.