PDA

View Full Version : CheckBox can't be showed in list



zhangwl
6 Dec 2010, 7:00 PM
in kitchensink list demo,

itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}<input id="{firstName}" type="checkbox" name="{lastName}"/></div>'

checkbox can't be showed.

I'm not sure if it is a bug?

sim4life
9 Dec 2010, 3:11 AM
Yes I did get a workaround working...
I used the itemTpl property of the List control with the tpl looking like:


<textarea id="todos-template" class="x-hidden-display">
<div id="todo_item_{todo_id}" class="todo_list">
<input type="checkbox" id="todo_check_{todo_id}" class="todo_checkbox unchecked"/> <strong>{title}</strong>
</div>
</textarea>

and the

itemtap: function(dataview, index, item, event) {
var todo = dataview.store.getAt(index).data;
if (eve.getTarget('input#todo_check_'+todo.todo_id)) {
Ext.get(item).addCls('selected');
ele = Ext.get('todo_check_'+todo.todo_id);

//reverse condition as the event is fired before the state is set
if(!ele.getAttribute('checked')) {
todo.completed_at = Api.formatDate(new Date());
ele.replaceCls('unchecked', 'checked');
} else {
ele.replaceCls('checked', 'unchecked');
todo.completed_at = null;
}
}

So on tapping the list item, I detect whether the checkbox is tapped and change the relevant div CSS classes accordingly. I hope the same thing can work for radio as well.