Dt-2.0 api useage

Dt-2.0 api useage

jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

The admin areas of my site uses the following structure...

Page Form
Table of records from Db

The usage scenario is...

1. Page 'ready' - Load table from Db and clear_Form() { reset_TableSort( oTable ); }
2. Select row from table - fill form with data
3. Update/edit form fields as needed
4. Submit form - update record in Db and clear_Form()

The problem occurs in the reset_TableSort function...

function reset_TableSort( thisTable ) {
    //  Remove highlight of selected row
    thisTable.rows('.selected').nodes().to$().removeClass('selected');
    //  Set sort order to original order
    thisTable.order.neutral().draw();
}

In v1.0 I could pass the current oTable value to the function. But with v2.0 this does not work. I've tried passing this.api()

reset_TableSort( this.api() );

but this throws an error... thisTable.order.natural is not a function

What do I need to change in the reset_TableSort function to make it work?

As always... TIA for your GREAT assistance
jdadwilson

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,188Questions: 26Answers: 4,925
    Answer ✓

    In v1.0 I could pass the current oTable value to the function. . But with v2.0 this does not work.

    What happens, do you get errors in the console?

    I've tried passing this.api() but this throws an error... thisTable.order.natural is not a function

    Like this.api() is not applicable from where reset_TableSort( this.api() ); is executed.

    What do I need to change in the reset_TableSort function to make it work?

    Its hard to say without seeing the problem to debug it. Did you load the order.neutral() plugin?

    The plugin works in this test case with 2.0:
    https://live.datatables.net/vewoxivu/1/edit

    If you still need help please post a link to a test case showing the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

    Had not loaded the plugin. That did the trick.

    Thanks again.. I'm sure I'll find some other problems as I continue to test different modules.

    jdadwilson

Sign In or Register to comment.