Alternative Editing

Alternative Editing

anotherlawanotherlaw Posts: 7Questions: 4Answers: 0

Might I ask for some advice on whether the following is possible with Editor?

I'm developing a competition scoring system using DataTables Editor and it is all working really well thanks to the super DataTables platform.

Currently users have to find the relevant competitor, then click to edit; which as some users are less IT savvy - the extra navigation needs can double or treble the time taken to input scores.

What I'd like to do is to allow the user to switch to an alternative view that allows them to key in 'competitor number' followed by the scoring data for that competitor ... hit return and then repeat for the next competitor .... ideally each input being shown in. a table on screen with the data being saved in the background.

I'd started developing this in JS/PHP but it seems silly that I'm replicating the same logic in DataTables.

Thoughts? and thanks in advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Answer ✓

    Presumably Competitor number is unique, so what you could do is take the value from the input there and find the corresponding record in the DataTable, then edit and submit that using the API - for example:

    var compNumber = $('#compeititorNumber').val();
    var score = $('#score').val();
    
    var rowIdx = table
      .row( function ( idx, data, node ) {
        return data.compeititorNumber == compNumber;
      } )
      .index();
    
    editor
      .edit( rowIdx, false )
      .set( 'score', score )
      .submit();
    

    Obviously you might need to update the parameter names, but basically that's the idea (the key perhaps being using the function for the selector to pick out the required row for the competitor number).

    Allan

  • anotherlawanotherlaw Posts: 7Questions: 4Answers: 0

    Awesome - thanks for the insight - love DataTables!

This discussion has been closed.