I have come across this a lot in ExtJS and I was wondering where it's coming from I have an example like this:
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
}),
Where is {text} coming from in this function? It's not been set like var text; anywhere in the script. Can I manipulate it like a normal string? Any insight on this would be helpful,
Thanks
That's a template. Somewhere in the rest of the code, the {text} in that string will be replaced with a value at run time.
Update:
Okay, look, you can do pretty much anything you want with it. I've don't have Ext.js handy so I can't give you straight-up code. but that argument is just an anonymous object. The new operation there creates an object, and uses that stuff as part of the contents. view will become the name of an attribute attached to SOMETHING -- to the window object if nothing else -- naming that new object.
If you want to know what's in it, console.dir in a debugger should dump out the contents. In those contents is almost certainly a string named groupTextTpl, and that's just a string, do with it as you will.
More probably, though, read up on template processing in Ext.js -- you can probably write code to use that template and make new, customized coipies from it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With