View Full Version : DataView and DataMap... no ability to set some sort of template

13 May 2012, 12:07 PM
Just attempting to create a DataView with Items... looks pretty cool but I'm wondering if theres any way to set some sort of template for the dataMap you define.

I need to create a label like:

<b>{time}</b> {name}

but it seems the datamap only lets me set one value like:

dataMap: {
getEventTitle: {
setHtml: 'name'

So in that case I only get a label with that. Is there any way around this? Seems a little limiting and if it's like this I'm surprised I'm the only person with a usecase for this :D


13 May 2012, 12:39 PM
Found some sort of workaround but it doesn't seem right still...

On my Ext.dataview.component.DataItem I set a custom property with a tpl property like so:

eventTitle: {tpl: '<b>{startTime}</b> {name}'}

I set my dataMap to call the function setData, like so:

config: {
dataMap: {
setData : {}

and inside my setData function:

setData: function () {
var eventTitle = this.getEventTitle(),
record = this.getRecord(),
data = {
name: record.get('name'),
startTime: record.get('startTime')



Is this the actual way I should be doing it or?

14 May 2012, 8:57 AM
Sigh... I just do not get the DataView and DataMap. So far through all of this it is the worst aspect of ST2 that I've come across. The documentation is terrible and non-real world.

It seems fine if you want to have a ul > li list of names and perhaps a button but in the real world it's SO much more complex than that.

The examples and use-case seem to be for single parameter setting, which again just does not make sense. Overriding the updateRecord does not make sense... how am I supposed to override it to allow say 2 parameters for one use case and then expect 1 for the rest of them.

I have loads of containers just to get my View to display properly and the example given (for a rich UI experience...) is a one line piece of text that's created with setText(param).

After spending at least 2 days messing around with this it seems that I've wasted my time and I don't think I can benefit from any of the DataItem properties, methods.

I basically want a template with Sencha components created like this (and unfortunately it doesn't seem to work this way).

<tpl loop=".">
<div class="titleBar">
<div class="container">
<img src="something" />
<label><b>{startTime}</b> {name}</label>
<div class="container">
<div class="segmentedButton">
<tpl loop="events">

Sorry if I sound a bit frustrated but its inevitable when it takes you 2 days to get nowhere...

28 May 2013, 12:52 AM
Hi intellix,
I'm facing the same issue. Have you find a solution?

i'm trying:

dataMap: {

getButton: {
setText: 'name' + 'distance'

with name an distance 2 filed of my store. no success. Thanks for your help!!

28 May 2013, 2:07 AM
It's been quite long but I know for a fact I'm no longer using DataMap. I went for using "updateRecord" method in all of my DataViews because then you can do exactly what you want with the highly limited DataViews

28 May 2013, 5:05 PM
Thanks for the Tip. I will look into updateRecord.