Set(), multiSet(). Both are not working.

Set(), multiSet(). Both are not working.

kooliebwoykooliebwoy Posts: 7Questions: 3Answers: 0

Hey Guys,

I can't seem to figure out why it is not allowing me to set the value for a field when doing multi row editing.

I have tried multiple ways based on the examples provided for Datatables Editor.

This is my code so far. I can see it is submitting the data and getting the data back from the database using .submit() and .preSubmit() functions. On the preSubmit functions I can clearly see the value is not set to what I originally set it to. That is my problem. Any help will do. Thanks in advance.

{
                        text: "Approve",
                        action: function ( e, dt, node, config ) {
                            
                            editor.edit(table.rows( { selected: true } ).indexes(), false);

                            var rows = editor.multiGet('approvedpaysheet.is_active');

                            $.each(rows, function(id){
                                editor.field('approvedpaysheet.is_active').multiSet(id, '1');
                            });

                            editor.submit();

                        }
                    }

This is the data that is shown on preSubmit. (Screenshot Attached)

Answers

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Hi,

    Any chance you can give me a link to the page showing the issue so I can step through it? The code above does look like it should work!

    In fact, since you are setting them all to 1 you should be able to just use:

    editor.field( 'approvedpaysheet.is_active' ).val( 1 );
    

    Allan

  • kooliebwoykooliebwoy Posts: 7Questions: 3Answers: 0

    Hi Allan,

    :( I am hosting it on my local machine.

    editor.field( 'approvedpaysheet.is_active' ).val( 1 );

    ^^ I tried that and it didn't work. Also, I only want it to work for the rows that I selected. I have no idea why it does not want to set the value to 1. Everything else works except that.

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Can you show me how you are defining the approvedpaysheet.is_active field? Is it actually a number 1 as the value, or is it possible a string "1" value?

    Allan

This discussion has been closed.