Hello,
It′s possible to set templates for ListView through javascriptor load a string with the declarative template?
Thanks,
Ivan Paulovich
first you must create and register class template
Type.registerNamespace(
"ViewTemplate" );ViewTemplate.MainTemplate =
function( element ) {var _element = element;this.createInstance =function( containerElement, dataContext, instanceElementCreatedCallback, callbackContext ){var result =new Sys.TemplateInstance();result.instanceElement = _element.cloneNode(
true );if( !Sys.Application.getMarkupContext().findObject( element.id ) ) {Sys.Application.getMarkupContext().addObject( element.id, element );
}
result.callbackResult = result.instanceElement.childNodes[0];
containerElement.appendChild( result.instanceElement );
createControls(dataContext);
return result;}
this.initialize =function() {if( _element.parentNode ){_element.parentNode.removeChild( _element );
}
}
this.dispose =function() {_element =
null;}
}
ViewTemplate.MainTemplate.registerClass(
"ViewTemplate.MainTemplate",null, Sys.UI.ITemplate, Sys.IDisposable );
then
var itemView =new Sys.UI.Data.ItemView($("itemView"));
var itemplate =new ViewTemplate.MainTemplate($("template"));itemView.set_itemTemplate(itemplate);
itemplate.initialize();
itemView.initialize();
No comments:
Post a Comment