Dynamic Select List Depending on Row Number?
Dynamic Select List Depending on Row Number?
This function:
function getList() {
return {"Orange" : 1, "Apple" : 2};
}
works fine and it is called from here:
"ipOpts": getList()
I want getList() to return different objects depending on the number of the selected row.
How do I get the row number of the row being edited?
This :
alert('Row index: ' + table.row( this ).index());
returns an object and not the index.
Also, now that I tested with the alert, I see that getList() is not called for each row. So I also need to know where to put the code to initialize the list per row.
Thanks.
This discussion has been closed.
Replies
When you say "row number", what number is it you want. The code you have should give an index, but you could also use
row().data()
if it is an id that you want and it is contained in the row's data.I would suggest probably using
open
as the event to listen for, although you could also have an event listener attached to the rows in the table that will update the options (using theupdate()
method of theselect
type).Allan
Thanks for the reply. The row number of the row in the grid that a given select box is attached to.
In other words....
If grid row = 1 then show objListA
Else show objListB
Thanks for the reply. Is it the row index you want, or a data property in the row that you want? The row index (
row().index()
) is really relevant to DataTables only and it could change if you delete some rows for example.Allan