Hybrid View

  1. #1
    Ext User
    Join Date
    Jun 2008
    Posts
    10
    Vote Rating
    0
    mundy is on a distinguished road

      0  

    Default Checkbox in a Grid Column (not for selection)

    Checkbox in a Grid Column (not for selection)


    I've done a bit of searching the forums and Google on this, but haven't had much luck.

    What I want to do is place a checkbox column into my grid, not for row selection but to show a value.

    I'll describe what I have so far...

    Basically its just a very basic Grid that lists users for a small intranet I'm making. It shows things like name, email, login, job title etc... One of the fields is "disabled" which if yes means their account is disabled and cannot be used.

    What I want to be able to do is use a checkbox in this column to first display the account disabled state (on/off, true/false etc) and second tie a listener to it so that when the user toggles it, update the users account etc.

    Is this possible? From my searching all I've found is discussion and how-tos on using the CheckboxSelectionModel class, which isn't what I'm after.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,991
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Could you just use a renderer? A renderer lets you alter what is displayed in a cell when the grid is rendered.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext User
    Join Date
    Jun 2008
    Posts
    10
    Vote Rating
    0
    mundy is on a distinguished road

      0  

    Default


    Hmm... I never thought of that (still somewhat new to Ext)

    I'll give it a go.

  4. #4
    Ext User
    Join Date
    Jun 2008
    Posts
    10
    Vote Rating
    0
    mundy is on a distinguished road

      0  

    Default


    I'm having some issues... I'm not even 100% sure I'm doing this right.

    Here is my code for the column:
    Code:
    {header: "Disabled", dataIndex: 'disabled', width: 70,
                renderer: function(value, cell) {
                    var cb = new Ext.form.Checkbox(
                        {
                            hideLabel: true,
                            renderTo: cell,
                            checked: value
                        }
                    );
                }
    }
    Using this code, the grid and the headers load but no data is shown.

    What am I doing wrong?

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,991
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      1  

    Default


    Lower level

    Code:
    renderer: function(value, cell)
    {
       return '<input type="checkbox" />';
    }
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Ext User
    Join Date
    Jun 2008
    Posts
    10
    Vote Rating
    0
    mundy is on a distinguished road

      0  

    Default


    oh ok...

    Would I then be able to use ext to add listeners etc to that checkbox?

    EDIT:

    Wait nevermind, I'm pretty sure I just answered my own question. Thanks for the help evant =)