PDA

View Full Version : Air + Ext.Template (again)



RobSmith
28 Apr 2008, 12:51 AM
As some of you mentioned before, there is a problem using templates in air. I was used to declaring templates out of the context object for instance:

Rather:

tpl: new Ext.XTemplate(
'<tpl for="."><div class="x-combo-list-item">{separator}</div></tpl>'
),

Than:

tpl: '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>'

This works fine for me. But now I want to use a GroupingView as part of a Grid. Defining this view it is not possible (or is it?) to specify a template object but a string which represents the template (in config option "groupTextTpl"). And again I got the security alert. Is there any way around this except of extending the GroupingView which would be my last option?

Thanks in advance and regards

Rob

devnull
28 Apr 2008, 7:27 AM
As I understand it, you could use a non-application sandbox and create a bridge to it, since you can execute (eval) arbitrary code there. I have not done this yet so I am not knowledgable on the details, buts thats how it should work.
I would also assume that you can feed an actual template in the same as you have in the first example though, have you tried it?

RobSmith
29 Apr 2008, 3:33 AM
I tried it and as it is written down in the API, the "groupTextTpl" config option expects a string.

Thanks for your comment, I will have a closer look to the sandbox bridge.

devnull
29 Apr 2008, 7:34 AM
Actually I dont think the sandbox bridge would help here come to think of it, or at least it would still require modifying the groupingView source to use it.
I got curious so I poked around in the groupingView source a bit:


if(!this.startGroup){
this.startGroup = new Ext.XTemplate(
'<div id="{groupId}" class="x-grid-group {cls}">',
'<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div>', this.groupTextTpl ,'</div></div>',
'<div id="{groupId}-bd" class="x-grid-group-body">'
);
}

So you are right that it will only accept a string, but it also looks like you can provide the whole template instead as startGroup :)

RobSmith
30 Apr 2008, 3:22 AM
You are great, mate. Thanks a lot.

bjt
23 Jun 2008, 2:25 AM
I have the same problem with the groupingView.
How i have to use the code that devnull posted?

Where i have to place it?

RobSmith
23 Jun 2008, 3:46 AM
You can extend the GroupingView class by defining the startGroup property in the constuctor. Having not worked before with extending Ext classes, I would suggest you to read the the docs, there are a couple of them treating this issue.

rob

Edit: Btw the code, devnull posted is not going to be inserted as it is already part of the GroupingView class. Devnull just pointed to the place where to look.

deep32
5 Jul 2008, 7:09 AM
Rob Smith i m also having the same problem

RobSmith
7 Jul 2008, 2:13 AM
Hi deep32.

Did the solution posted above work for you? Do you need any help?

Regards

Rob

bjt
23 Jul 2008, 2:40 AM
i need the groupingView again and now i want to solve the problem.

@devnull i found the source you posted in the ext-all-debug.js file.
I think the problem is the same like the combobox tpl problem. The template not rendered at load time.

What should i have todo to make the groupingview running?

I think i only had to load the groupingview template at the right place to the right time.
But i dont know where and when. please help and describe the way to solve this security sandbox problem for the groupingview

kim
11 Sep 2008, 12:30 AM
add the following to your code

Ext.grid.GroupingView.override({
initTemplates: function(){
Ext.grid.GroupingView.superclass.initTemplates.call(this);
this.state = {};

var sm = this.grid.getSelectionModel();
sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect', this.onBeforeRowSelect, this);

this.startGroup.compile();
this.endGroup = '</div></div>';
}
});

create template before onReady

var tpl = new Ext.XTemplate('<div id="{groupId}" class="x-grid-group {cls}">',
'<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div>{text}</div></div>',
'<div id="{groupId}-bd" class="x-grid-group-body">')

create grid


var grid = new Ext.grid.GridPanel({
...
view: new Ext.grid.GroupingView({
...
startGroup: tpl,
...
}),
...
});