Hybrid View
-
30 Jul 2008 8:22 PM #1
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.
-
30 Jul 2008 8:25 PM #2
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!
-
30 Jul 2008 9:13 PM #3
Hmm... I never thought of that (still somewhat new to Ext)
I'll give it a go.
-
30 Jul 2008 9:32 PM #4
I'm having some issues... I'm not even 100% sure I'm doing this right.
Here is my code for the column:
Using this code, the grid and the headers load but no data is shown.Code:{header: "Disabled", dataIndex: 'disabled', width: 70, renderer: function(value, cell) { var cb = new Ext.form.Checkbox( { hideLabel: true, renderTo: cell, checked: value } ); } }
What am I doing wrong?
-
30 Jul 2008 9:35 PM #5
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!
-
30 Jul 2008 9:37 PM #6
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 =)


Reply With Quote