Im looking for an example of using an Inline Select...

Im looking for an example of using an Inline Select...

wachesonwacheson Posts: 5Questions: 2Answers: 0

I've got the Grid view and Editor working well for regular inline edits, but I cant seem to figure out the trick for supporting the Select.
so far, when I click the td, the dropdown appears, and I can pick one, but there doesn't seem to be an event for grabbing that change.
Im assuming I need something taylored to be similar to this, but just for my select columns?
$('#report_data_tbl').on( 'click', 'tbody td', function (e) {
$editor.inline( this )
});

This question has an accepted answers - jump to answer

Answers

  • wachesonwacheson Posts: 5Questions: 2Answers: 0

    By default, inputs submit fine, but Selects do not. I did get Selects to submit with submitOnBlur works on the selects, but I was hoping to use Return to initiate the submits, and blur as a cancel, for both tyoes... is there an easy way to split that out?

  • larsonatorlarsonator Posts: 54Questions: 4Answers: 2

    you could give them all a similar class name:

    $("select.classname").on('change', function(){
        //get datatable data
        var data = MyDataTable.row($(this).closest('tr')).data();
        //get the selected option
        var option = $('option:selected', $(this));
    });
    
  • wachesonwacheson Posts: 5Questions: 2Answers: 0

    Hmm, ok. I'll tinker with it and some more and see whats going to work. Thanks for the idea.

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

    Hi,

    Editor has a built in function that it uses to determine if a return key press should be used as a submit command or not. It will match all input element types, but it doesn't currently match on select elements.

    The problem with doing a return on select is that there doesn't appear to be any way to distinguish between a return key press to select a value in the list via keyboard, and a return when the element is just focused.

    That is the reason why Editor doesn't doing submitOnReturn for the select lists. If there is a way to distinguish between the two states, then I think this would be a great addition.

    Allan

  • wachesonwacheson Posts: 5Questions: 2Answers: 0

    ok, That makes sense. To speed dev up, I think I'll just switch it to one of the popup forms and perhaps I can do what I want to with bubble,and if not, then primary. Im assuming I can find a way to click on the row, and it pop up the primary form window, vs having to click the Edit button...

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

    You could try bubble editing perhaps? Or inline with a submit button?

    Allan

  • mkleinoskymkleinosky Posts: 46Questions: 6Answers: 5

    how do I use inline editing without a submit button on text fields and inline editign with a button for select fields?

  • mkleinoskymkleinosky Posts: 46Questions: 6Answers: 5

    // Select all elements with a data-editor-field attribute
    $('*[data-editor-field]').on( 'click', function () {
    editor.inline( this );
    } );

    $('#training').on( 'click', 'tbody td', function () {
    editor.inline( this );
    } );

    are in my code - but how do I use button with ONLY select fields?

    $('#training').on( 'click', 'tbody td', function () {
    editor.inline( this, {
    buttons: { label: '>', fn: function () { this.submit(); } }
    } );

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

    You need to call inline() as appropriate, using the code you have above. You would need an if statement that would decide (based on column index perhaps?) if the submit button should be shown or not.

    Allan

This discussion has been closed.