I am trying to have a sparkline in the cell of a treegrid. There is a jquery component (omnipotent.net/jquery.sparkline/) I can use in normal html that works fine.
Inline Sparkline: 1,4,4,7,5,9,10.
However I can’t seem to get this in a cell to render.
I tried several options. This being the most recent. This simply writes out 1,2,3,4,32
<![CDATA[
1,2,3,4,32
]]>
Thanks
Such issue may occur if by the time of executing sparkline script necessary row is not loaded yet. So sparkline script don’t know which span it needs to merge.
By the way, there is inbuilt rowspan and colspan functionality in Grid and TreeGrid. Please find more information here dhtmlx.com/dhxdocs/doku.php?id=d … pulation&s[]=merge&s[]=cells#merging_cells
Thanks for the response. I assumed it was something about the execution of the script, though I’m not sure how to address that.
Here is the HTML code.
Attach dhtmlxTreeGrid to Layout
Sample Inline Sparkline: 1,4,4,7,5,9,10.
Here is the XML,
<?xml version="1.0" encoding="UTF-8"?>
Metric
Current Week
LY Same Week
Mobile Phones
Nokia
<![CDATA[1,2,3,4,32]]>
<b>1
23
Test
123
249
Nokia 6500 classic
1
320
Sony Ericsson
Sony Ericsson K800i
1
228
Sony Ericsson W950i Walkman
1
289
Any thoughts on how to get the script loaded in time?
Thanks again.
Try to call sparkline function after treeGrid was fully loaded:
dhxTreeGrid.loadXML("…/common/treegrid.xml?etc="+new Date().getTime(),function(){
$(function() {
/** This code runs when everything has been loaded on the page /
/ Inline sparklines take their values from the contents of the tag /
$(’.inlinesparkline’).sparkline();
/ Sparklines can also take their values from the first argument passed to the sparkline() function /
var myvalues = [10,8,5,7,4,4,1];
$(’.dynamicsparkline’).sparkline(myvalues);
/ The second argument gives options such as chart type /
$(’.dynamicbar’).sparkline(myvalues, {type: ‘bar’, barColor: ‘green’} );
/ Use ‘html’ instead of an array of values to pass options to a sparkline with data in the tag */
$(’.inlinebar’).sparkline(‘html’, {type: ‘bar’, barColor: ‘red’} ); })
});
Again thank you and please be patient with me as this is pretty new to me.
I just don’t understand how to call the function after the tree grid was loaded. That function will place data in cells. Therefore it has to be in the XML correct? Right now the XML gets loaded last in the OnLoad function. Is there a trick to call
dhxTreeGrid.loadXML("…/common/treegrid.xml?etc="+new Date().getTime());
sometime after the onLoad?
Thank you again.
I just don’t understand how to call the function after the tree grid was loaded.
To detect if treeGrid rows were loaded you can use 2nd parameter of loadXML() method. 2nd parameter of laodXML() method is after loading callback function:
dhxTreeGrid.loadXML("…/common/treegrid.xml?etc="+new Date().getTime(),doOnTreeGridLoad);
function doOnTreeGridLoad(){
//call sparkline function.
}
Please check sparkline documentation to find out how to call this script correctly after Ajax response is finished.
>>Right now the XML gets loaded last in the OnLoad function. Is there a trick to call
dhxTreeGrid.loadXML("…/common/treegrid.xml?etc="+new Date().getTime());
sometime after the onLoad?
In your code dhxTreeGrid.loadXML("…/common/treegrid.xml?etc="+new Date().getTime()); is called right after onLoad() as it is the last line of the onLoad() function.