Skip to content

array input element with checkbox group . #23

Description

@saurovh

hi everyone i have tried this plugin. i need to input a group checkbox as array to submit in page. Its working on submitting. and backend updates work perfectly. but when update complete if i try to edit again then then its don't update data.record variable on that plugin . here is the sample code can anyone help ?

here access and modify is the html array input which work on submit...

$(document).ready(function () {
var access_list = new Array();
var value_list = new Array();

$show) { ?>
                                                         access_list.push('<?php echo $class; ?>');
                                                         value_list.push('<?php echo $show; ?>');
                                                             //Prepare jTable
$('#main_content').jtable({
    title: 'User Group List',
    actions: {
        listAction:   'muurl',
        createAction: 'muurl',
        updateAction:  'muurl',
        deleteAction: 'muurl',
    },
    fields: {
        id: {
            key: true,
            create: false,
            edit: false,
            list: false
        },
        groupName: {
            title: 'Group Name',
            width: '40%'
        },
        access: {
            title: 'Access Permission',
            width: '12%',
            //                                                 list: false,
            input: function (data) {
                var str ='';
                if (data.record) {
                    for(var i=0;i<access_list.length;i++){
                        if(jQuery.inArray(access_list[i], data.record.access)!= -1){
                            str += '<input type="checkbox" name="access[]" value="'+access_list[i]+'" checked="checked" />'+value_list[i]+'<br/>';
                        }else{
                            str += '<input type="checkbox" name="access[]" value="'+access_list[i]+'" />'+value_list[i]+'<br/>'; 
                        } 
                    }
                } else {
                    for(var i=0;i<access_list.length;i++){
                        str += '<input type="checkbox" name="access[]" value="'+access_list[i]+'" />'+value_list[i]+'<br/>'; 

                    }
                }
                return str;    
            }

        },
        modify: {
            title: 'Modify Permission',
            width: '12%',
            //                                                 list: false,
            input: function (data) {
                var str ='';

                if (data.record) {
                    for(var i=0;i<access_list.length;i++){
                        if(jQuery.inArray(access_list[i], data.record.access)!= -1){
                            str += '<input type="checkbox" name="modify[]" value="'+access_list[i]+'" checked="checked" />'+value_list[i]+'<br/>';
                        }else{
                            str += '<input type="checkbox" name="modify[]" value="'+access_list[i]+'" />'+value_list[i]+'<br/>'; 
                        } 
                    }
                } else {
                    for(var i=0;i<access_list.length;i++){
                        str += '<input type="checkbox" name="modify[]" value="'+access_list[i]+'" />'+value_list[i]+'<br/>'; 

                    }
                }
                return str;    

            }

        }
    }
});


//Load person list from server
$('#main_content').jtable('load');

});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions