PDA

View Full Version : Inner div inside itemTpl for data view



mwilliamsShields
15 Aug 2014, 11:43 AM
I am using a data view to display inbox message threads in my applications internal messaging system. I am trying use an itemTpl to make it so sent messages display in a different color box from received messages. Since the itemTpl only allows me to edit the inner content of the item's div element I am adding no styling to the outer div element and trying to add a div in the item template with the styling class for a sent message if the item is a message that was sent from the user viewing the message, and the styling class for a received message if not.

My problem is that when I try using a div element inside of the itemTpl it stops the data from rendering.

Why can I not use a div inside of an itemTpl?

Is there another way I can do what I am trying to do?

skirtle
15 Aug 2014, 1:11 PM
You should be able to include just about any valid HTML markup inside an itemTpl. My guess is there's an error in the template that's being swallowed. Try setting your browser's dev tools to break on all errors, see what that throws up.

You could also consider using a tpl instead of an itemTpl (see the source to see how the two are related). That may allow you to avoid the unnecessary extra elements.

If you need further help I suggest that you put together a Fiddle (http://www.sencha.com/forum/showthread.php?268535) so that we can see the problem for ourselves.

mwilliamsShields
18 Aug 2014, 7:11 AM
You are right. Whenever I use a div tag in the itemTpl there is an error that of "Cannot read property 'internalId' of undefined." I am looking into why this error only happens when I use a div

mwilliamsShields
18 Aug 2014, 7:39 AM
So it turns out that I had the itemSelector config in the view set to div which was causing the itemTpl to throw an error when there was a div in there. I just set the itemSelector config to empty and it fixed the problem.