Dynamic Select List Depending on Row Number?

Dynamic Select List Depending on Row Number?

Karl53Karl53 Posts: 72Questions: 29Answers: 0

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.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    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.

    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.

    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 the update() method of the select type).

    Allan

  • Karl53Karl53 Posts: 72Questions: 29Answers: 0

    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

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    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

This discussion has been closed.