Datatable column with dynamic dropdown
Datatable column with dynamic dropdown
New user of datatable here.
I wanted to know how can I achieve the following with datatables:
I need to have 5 columns, where in first column would need to have a dynamic dropdrownlist.
The dropdownlist needs to be populated from a button click event that happens before the page.
There would be add new row button, when the user clicks add new row, it would create a new row in the grid.
When they make any selection in the first column, all other column values are prefilled with some data (some logic from my end) and would be disabled.
So just wanted to know how can I get started with this.
Would appreciate inputs.
Answers
This example shows how you can dynamically build a
select
input based on the options in a column. That would be my starting point.Allan
Thanks alan. The example you have shared is for searching. What event would be available if I want to create select within the grid itself.
And secondly when the user clicks on add row, the new row would be created having the first column as dropdownlist. They may keep adding row.
Then there is a button at the end that says save where I want to save all the data of the datatable to my db. Is this something doable by datatable.
Thanks
Do you mean a
select
element inside a cell? Usecolumns.render
to control what is shown inside a cell.Allan
Yes select tag. I will try that out and post result.
Thanks