Sending a variable to the DataTable and displaying it.
Sending a variable to the DataTable and displaying it.
bobs64956
Posts: 18Questions: 6Answers: 0
Hey,
I was wondering if it is possible for the user to select an option from a drop-down menu in which it will set the value within the datatable.
//HTML Drop-down menu in which the user will select and set the value
<div class="form-group">
<select name="filter_gmrate" id="filter_gmrate" class="form-control" required>
<option value="">Select Gross Margin Rate</option>
@foreach($gmrrate_name as $gmrate)
<option value="{{ $gmrate->gmrRate }}">{{ $gmrate->gmrRate }}</option>
@endforeach
</select>
</div>
<div class="form-group" align="center">
<button type="button" name="gmrateset" id="gmrateset" class="btn btn-info">Set Gross Margin Rate</button>
</div>
</div>
//In the Datatables column, its being displayed like this
{
"data": null,
"render": function(data,type,row) {
return filter_gmrate;
}
},
//When clicking on the button, it will set the value (Just unsure how to destroy and display the new data)
$('#gmrateset').click(function(){
var filter_gmrate = $('#filter_gmrate').val(); //sets the value of gmrate
console.log(filter_gmrate);
$('#jobprice_data').DataTable().destroy();
fill_datatable();
});
This discussion has been closed.
Answers
Yes, by using Editor with inline editing.
Here is an example from my own coding: