Inline editing - multiple fields in one column

Inline editing - multiple fields in one column

waseemlywaseemly Posts: 7Questions: 3Answers: 1

Hi

I am using DataTables for a complex (ish) project and have coded my own backend code in Laravel . So I have to show a list of passwords which belong to a user all in one column. ie email password, ftp password etc etc

I bring this back as field (but its an array).

Displaying the various password is the easy bit and i have it working thus via a render method that looks like this

var userPasswords = function (data, type, row) {

        if (type === 'display') {
           var userPasswordList = '';
                data.forEach(function(element) {
                    userPasswordList = userPasswordList + ' ' +  element.type +  ' <i class="fa fa-eye user-pass" data-pass="' + element.password + '"/>';
            });

            return  userPasswordList ;
        }
            return data;
};

However i want to click on the eye icon and then it allows me to edit the specific field my edit method looks like this

$('#table tbody').on('click', 'td i.user-pass', function (e) {


          
            e.stopImmediatePropagation(); // stop the row selection when clicking on an icon
            editor.inline($(this).parent());



            });

this shows Object.object, Object.object , in the inline input field as the original field pulled back as 2 items in the array.

Is there anyway i can choose the specific field i need?

Also i will need to decrypt these before i show it in the inline input, so will need to make an Ajax call. I think the editor.inline methods only takes am actual column and can't accept string values.

I have added a simple screen shot to show what the column looks like, so clicking on windows (eye icon) id want the windows password to show , clicking on unix id want the unix one to show etc...

Any pointers would be very helpful I have tried a few things but none of them work as I am not passing in the right kind of data to editor.inline

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Inline editing isn't going to work for an array input I'm afraid - at least not at an individual level. You could have it do string editing of all passwords in a single input, or you could have individual inputs based on the array, but they would all need to be shown, and that would need to be created as a field type plug-in for Editor.

    Perhaps one option would be to use bubble editing, but I think the click event to trigger the edit would need to dynamically add the field to be edited (referencing the right index in the password - name: 'password.2' for example. Adding and removing passwords would also be tricky there.

    How are the passwords stored in the db? Perhaps showing a child table with the list of editable passwords might be an option?

    Regards,
    Allan

  • waseemlywaseemly Posts: 7Questions: 3Answers: 1

    Hi Allan

    Client kind of changed their mind they didn't want it like that anyway so was ok.

This discussion has been closed.