Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: adding a checkbox to a ListView column

  1. #1
    Sencha User
    Join Date
    Jan 2011
    Location
    Lincoln RI
    Posts
    97
    Vote Rating
    0
      0  

    Default 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.

  2. #2
    Sencha User jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
      0  

    Default

    You could paste a template string into the "tpl" configuration for your column. That would be the easiest way most likely.

  3. #3
    Sencha User
    Join Date
    Jan 2011
    Location
    Lincoln RI
    Posts
    97
    Vote Rating
    0
      0  

    Default

    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.

  4. #4
    Sencha User jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
      0  

    Default

    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:

    Code:
    <input type="checkbox" disabled="disabled" <tpl if="active">checked="checked"</tpl> />
    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.

  5. #5
    Sencha User
    Join Date
    Jan 2011
    Location
    Lincoln RI
    Posts
    97
    Vote Rating
    0
      0  

    Default

    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 Ive 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> />
    

  6. #6
    Sencha User jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
      0  

    Default

    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.

  7. #7
    Sencha User
    Join Date
    Jan 2011
    Location
    Lincoln RI
    Posts
    97
    Vote Rating
    0
      0  

    Default

    yes i have it working now! Thank you so much.

  8. #8
    Sencha User jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Vote Rating
    7
      0  

    Default

    Terrific, good to hear

  9. #9
    Sencha User
    Join Date
    Jun 2007
    Posts
    21
    Vote Rating
    0
      0  

    Default

    Im testing a list based on the same code with a few change:

    Code:
    <input type="checkbox" <tpl if="selected === 'Y'">checked="checked"</tpl> />
    I cant check or uncheck the checkboxes. Those who initially was checked stay checked like it was read only.
    Any idea why it happend?
    Thanks.

  10. #10
    Sencha User
    Join Date
    Jun 2007
    Posts
    21
    Vote Rating
    0
      0  

    Arrow

    Ext.list.ListView is a fast and light-weight implentation of a Grid like view with the following characteristics:
    .......
    no editing
    .......
    "No editing" applies to the elements that are included in the template?

Page 1 of 2 12 LastLast

Similar Threads

  1. Adding Checkbox Column to a grid
    By mannyk in forum Ext Designer: Help & Discussion
    Replies: 2
    Last Post: 23 Aug 2010, 10:00 PM
  2. Checkbox Plus ListView
    By erizvi in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 9 Aug 2010, 5:10 PM
  3. adding checkbox dynamically to a checkbox group
    By muncher in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 19 Jul 2010, 12:46 PM
  4. [SOLVED] Adding Checkbox column in GridPanel via Ext Designer
    By Nightwish in forum Ext Designer: Help & Discussion
    Replies: 8
    Last Post: 6 Jul 2010, 7:25 PM
  5. how can I add checkbox in ListView's each item?
    By zzsnake in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 6 Aug 2009, 6:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •