Add columns in while

Add columns in while

xavstargatexavstargate Posts: 4Questions: 1Answers: 0

Hey,

This is my problem, I have this object :
[
Login : "azerty",
Email : "test@azert.com",
Permissions : [{
Label : "CanGet",
Value : false
},
{
Label : "IsAdmin",
Value : false
}]
]

I want create for each permission a column, is ok it's work ! But I can get the Value :((
I have a for for each columns in a list :smile:
["CanGet","IsAdmin]

      for (var i = 0; i < role.length; i++) {
            var ob = {
                title: role[i],
                data: function (row, type, val) {
                    if (row.Permissions[i].Value == true) { // <=====================
                        return '<input type="checkbox" checked><span class="text"></span>';
                    } else {
                        return '<input type="checkbox"><span class="text"></span>';
                    }
                }
            };
            UI.Module.ManageAPI.list.push(ob);
        }

UI.Module.ManageAPI.list : columns
i is always equal to the size of my list :(

Replies

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Sounds like you need to move UI.Module.ManageAPI.list.push(ob); into the permission check logic.

    Allan

  • xavstargatexavstargate Posts: 4Questions: 1Answers: 0

    I'm sorry but I don't understand.

    Why the title with "role[i]" is correct and why the "i" in data is not :(

     UI.Module.ManageAPI.list.push({
                    title: role[i],                                       <============= OK
                    data: "Permissions[" + i + "].Value",  <============= NOK
                    render: function (data, type, val) {
                        if (data) {
                            return '<input type="checkbox" checked><span class="text"></span>';
                        } else {
                            return '<input type="checkbox"><span class="text"></span>';
                        }
                    }
                });
    
  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'd need to be able to see a working example of the code please. It might be a closure issue, or I'm just missing something.

    Thanks,
    Allan

This discussion has been closed.