LA.NET [EN]

Oct 27

In these last posts, we’ve already met several of the events generated by the DataView control. I thought it would be a good idea to write a small post which documents many of the events we’ve seen in the past:

command: fired when a user clicks over an element which has been “marked” with the sys:command system attribute;

  • rendering: this event is generated when the DataView control is about to start instantiating its template to get the rendered HTML. Any function which handles this event receives two parameters: the first, references the DataView control which generated the event; the second is an instance of the Sys.Data.DataEventArgs type.;
  • rendered: marks the end of the HTML rendering process. Functions configured as handlers receive two parameters: the first, references the DataView which generated the event; the second, is an instance of the Sys.DataDataEventArgs type;
  • itemRendering: event that is generated before each item’s template instantiation. We can do several interesting things here, like changing the default template or influencing the data that is going to be used during the template instantiation;
  • itemRendered: event which signals the end of the instantiation of a template. We’ve seen how we can use this event to customize the generated HTML for an item.

The Sys.Data.DataEventArgs object used by the rendering and rendered events introduces some interesting properties:

  • data: references the items that will be used for instantiating the templates;
  • itemPlaceholder: used for identifying the place holder where the template’s generated HTML will be put;
  • itemTemplate: reference to the template used for instantiating all the elements.

During the rendering event, you can set all of these properties  and influence the HTML generated by the DataView control.

Besides these events, there are still others, but we’ll leave them for the next posts because they’re related with the integration of the DataView control with data contexts. Stay tuned for more on MS AJAX.

3 comments so far

  1. william apken
    10:57 am - 10-27-2009

    The Sys.Data.DataEventArgs object used by the rendering and rendered events introduces some interesting properties:

    data: references the items that will be used for instantiating the templates;
    itemPlaceholder: used for identifying the place holder where the template’s generated HTML will be put;
    itemTemplate: reference to the template used for instantiating all the elements.

    During the rendering event, you can set all of these properties and influence the HTML generated by the DataView control.

    Does that last statement only apply when you are using local data as opposed to using data returned by the fetchOperator ? In my case you would not use the data:property but rely on the fetchOperator.

  2. william apken
    10:58 am - 10-27-2009

    The Sys.Data.DataEventArgs object used by the rendering and rendered events introduces some interesting properties:

    data: references the items that will be used for instantiating the templates;
    itemPlaceholder: used for identifying the place holder where the template’s generated HTML will be put;
    itemTemplate: reference to the template used for instantiating all the elements.

    During the rendering event, you can set all of these properties and influence the HTML generated by the DataView control.

    Does that last statement only apply when you are using local data as opposed to using data returned by the fetchOperator ? In my case you would not use the data:property but rely on the fetchOperator.

  3. luisabreu
    11:03 am - 10-27-2009

    i”m still investigating the data context and derived classes. i”ll be returning to that topic in future posts :)

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>