This example is based on this demo.
It illustrates how to use the dxSparkline Data Visualization Widget in ASPxGridView Cells / DataItemTemplate:
- Define a custom HTML element with the specified "class" (for example, "elementClassToSelect" in order to access it via a selector on the client) and runat=server (in order to access it on the server) attributes and specified dimensions inside the DataItemTemplate;
- Use the K18282: The general technique of using the Init/Load event handler approach and handle this HTML element's Init event;
- Specify element's attribute (for example, "data") with some data (for example, the related record's one). Use the standard System.Web.Script.Serialization.JavaScriptSerializer.Serialize method to create a JSON string from an IEnumerable source.
- Handle the ASPxClientGridView Init/EndCallback events and initialize the dxSparkline widget (see the K18561: Using jQuery / jQuery UI libraries with DevExpress ASP.NET Controls / MVC Extensions #3):
- Select all targets to be transformed to dxSparkline via a class selector (according to the class attribute specified earlier);
- Transform all targets to the dxSparkline widget:
- Use the base settings for creating a dxSparkline widget;
- Specify an individual "dataSource" property retrieved from the element's ("data") attribute;
- Remove the ("data") attribute from the transformed element (if necessary).
It illustrates how to use the dxSparkline Data Visualization Widget in ASPxGridView Cells / DataItemTemplate:
- Define a custom HTML element with the specified "class" (for example, "elementClassToSelect" in order to access it via a selector on the client) and runat=server (in order to access it on the server) attributes and specified dimensions inside the DataItemTemplate;
- Use the K18282: The general technique of using the Init/Load event handler approach and handle this HTML element's Init event;
- Specify element's attribute (for example, "data") with some data (for example, the related record's one). Use the standard System.Web.Script.Serialization.JavaScriptSerializer.Serialize method to create a JSON string from an IEnumerable source.
- Handle the ASPxClientGridView Init/EndCallback events and initialize the dxSparkline widget (see the K18561: Using jQuery / jQuery UI libraries with DevExpress ASP.NET Controls / MVC Extensions #3):
- Select all targets to be transformed to dxSparkline via a class selector (according to the class attribute specified earlier);
- Transform all targets to the dxSparkline widget:
- Use the base settings for creating a dxSparkline widget;
- Specify an individual "dataSource" property retrieved from the element's ("data") attribute;
- Remove the ("data") attribute from the transformed element (if necessary).