-
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 =)
-
30 Jul 2008 10:03 PM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Isn't the Ext.grid.CheckColumn (from examples/grid/edit-grid.js) much better suited for this?
-
30 Jul 2008 10:13 PM #8
It appears you are correct.
I can't for the life of me find CheckColumn in the API documentation though. Am I missing something?
It clearly works in this example:
http://extjs.com/deploy/dev/examples...edit-grid.html
Thanks for that Condor
-
30 Jul 2008 10:19 PM #9
It's not an "official" class, just an example.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
31 Jul 2008 12:02 AM #10
It's not that useful though. You can't getChecked, or checkAll or uncheckAll which is what you might need to do with a column of checkboxes.
What about this: http://extjs.com/forum/showthread.php?t=31036 ?Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote