Focus Change events?

Focus Change events?

Mike StoreyMike Storey Posts: 25Questions: 7Answers: 0

I'm have some js that should execute anytime the row selection changes, but I'm not finding any UI interaction type events? Is there any way to attach some .js to the row selection event?
And on a related topic, what is the easiest way to find the "currently selected" row - assuming a SS data table?

An example of what I'm trying to a accomplish would be updating a "Heading" on the page with a value from the currently selected row.

Any help or advice is appreciated.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin
    Answer ✓

    Hi Mike,

    I'm have some js that should execute anytime the row selection changes

    Assuming you are using TableTools, the fnRowSelect and fnRowDeselected callbacks are currently how you can be informed of a change in row selection. I'm going to be working on a new selection plug-in for DataTables next month which will introduce "proper" events for this.

    And on a related topic, what is the easiest way to find the "currently selected" row - assuming a SS data table?

    Use the fnGetSelected, fnGetSelectedData or fnGetSelectedIndexes methods (docs).

    One thing to note, if you are using server-side processing, the row selection is for the current page only. If you change page and then back again, the row selection will be lost (again something that will be addressed...).

    Regards,
    Allan

  • Mike StoreyMike Storey Posts: 25Questions: 7Answers: 0
    edited January 2015

    Thanks for the pointer, here are snippets of what I worked out.

    <html>
    .... <span class="spanCustomerName">aName</span> ....
    </html>
    
    <script>
    ...
            "tableTools": {
                "sRowSelect": "single",
                "fnRowSelected": function ( nodes ) {
                    $( ".spanCustomerName" ).text( table.row(nodes).data().shortName );
    ....
    </script>
    
This discussion has been closed.