-
31 Jan 2011 8:37 AM #1
adding a checkbox to a ListView column
adding a checkbox to a ListView column
I have a listView with several columns. Two of the columns are true false, so I would like to display check boxes. In Ext designer, I have right licked on the column and chosen transform ListView Boolean column. The data is either “Y” or “N” and displays as either true or false. How can I get this to render as a checkbox? I also do not want the user to be able to change the data.
-
31 Jan 2011 10:09 AM #2Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
You could paste a template string into the "tpl" configuration for your column. That would be the easiest way most likely.
-
1 Feb 2011 5:48 AM #3
I tried using tpl and the checkbox displayed in the column and all were unchecked. The data has some checked and others unchecked. Also I was able to check and uncheck the checkbox. To implement the checkbox in a column, I suspect you need to right click on the column and transform it to a ListView BooleanColumn?
Then add the tpl?
Could you tell me or give me an example of what the tpl should be?
Do i need to add a listener? not sure how to do this with ext designer. Could you tell me how?
Thank you.
-
1 Feb 2011 9:22 AM #4Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
In the template, you can do conditional logic based on the boolean value. Let's say the field name is "active", you can do a conditional template like this:
At least that's the gist of it. Does that makes sense? You can read more on XTemplates here, just expand the constructor line to see the details and examples.Code:<input type="checkbox" disabled="disabled" <tpl if="active">checked="checked"</tpl> />
-
1 Feb 2011 1:01 PM #5
Yes what you are saying make sense. The data in the field is either “Y” or “N”, so I guess this is not a Boolean field as I previously stated. I am using a ListView column adding the tpl for the checkbox. I change the code a bit but I think I’ve got the syntax wrong. I have 3 rows and only the second should be checked. I am getting all rows checked. I have looked for examples but have not had much luck. Could you tell me what I am doing wrong. Also could you point me to any good references for this? Thank you.
Code:<input type="checkbox" disabled="disabled" <tpl if="dividendPolicy === 'Y'">checked="checked"</tpl> />
-
1 Feb 2011 1:59 PM #6Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
That looks correct to me. Are you sure dividendPolicy is not "Y" for all records? Is the field type in the store on "auto" or on "boolean"? If it's on boolean, try setting it to auto.
-
2 Feb 2011 5:51 AM #7
yes i have it working now! Thank you so much.
-
2 Feb 2011 10:22 AM #8Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
Terrific, good to hear

-
12 May 2011 6:49 AM #9
I´m testing a list based on the same code with a few change:
I can´t check or uncheck the checkboxes. Those who initially was checked stay checked like it was read only.Code:<input type="checkbox" <tpl if="selected === 'Y'">checked="checked"</tpl> />
Any idea why it happend?
Thanks.
-
12 May 2011 7:12 AM #10
"No editing" applies to the elements that are included in the template?Ext.list.ListView is a fast and light-weight implentation of a Grid like view with the following characteristics:
.......
no editing
.......
Similar Threads
-
Adding Checkbox Column to a grid
By mannyk in forum Ext Designer: Help & DiscussionReplies: 2Last Post: 23 Aug 2010, 10:00 PM -
Checkbox Plus ListView
By erizvi in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 9 Aug 2010, 5:10 PM -
adding checkbox dynamically to a checkbox group
By muncher in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 19 Jul 2010, 12:46 PM -
[SOLVED] Adding Checkbox column in GridPanel via Ext Designer
By Nightwish in forum Ext Designer: Help & DiscussionReplies: 8Last Post: 6 Jul 2010, 7:25 PM -
how can I add checkbox in ListView's each item?
By zzsnake in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 6 Aug 2009, 6:19 AM


Reply With Quote