User select row versus API select

User select row versus API select

warblewarble Posts: 1Questions: 1Answers: 0

Hi,
I've been looking for quite a while on the site, and I can't seem to find a way to tell the source of a select event. i.e. what triggered the event, a user click or an API call. The event objects seem to be identical.

Here's my situation - I'm syncronizing a leaflet map, with a datatable, each row in the datatable is a location on the map. I need to know if the user clicked on the table so that I can trigger the 'active' mode on the item in the map. This works fine by itself, I attach to the table.on('select', event, and send the map a message to update it's location.

BUT when I click on the map, I need to tell the table to select the corresponding row. Fine, I issue a table.row(id).select() API call, but that triggers the event - which updates the table, which you know the rest.

Sure - I can put some additional record-keeping in and probably get around this, but it seems really kludgy - I should be able to find the source of the event, and if it's undefined (in the case of an API call) I don't propegate further.

Any ideas? I can offer a patch to update this in the codebase if it doesn't exist.

Thank you!

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Yep, agreed, there does seem to be a missing event that would be useful to have. A workaround is to use a global variable within user-select, something like this. Not the most elegant, but it does work,

    Colin

  • BarryBBarryB Posts: 4Questions: 1Answers: 0

    See this thread for similar discussion with (kludgy) solution.

    H/T kthorngren

This discussion has been closed.