asp.net mvc 3 - jqGrid and Google Chart API -
is possible add graphs using google chart api or other graph 1 column of jqgrid? if possible, how? need filter each row of jqgrid , show graph of particular row in last column of jqgrid.
you use custom formatter:
<script type="text/javascript"> $(function () { $('#mygrid').jqgrid({ url: '@url.action("data")', datatype: 'json', colnames: [ 'foo', 'bar', 'chart' ], colmodel: [ { name: 'foo', index: 'foo' }, { name: 'bar', index: 'bar' }, { name: 'chart', index: 'chart', formatter: chartformatter }, ] }); }); function chartformatter(el, cval, opts) { return '<img src="' + el + '" alt="chart" title="" />'; } </script> <div style="height: 500px;"> <table id="mygrid"></table> </div>
and controller return corresponding google chart urls:
public actionresult data() { return json(new { rows = new[] { new { id = 1, cell = new[] { "foo 1", "bar 1", "https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=hello|world" } }, new { id = 2, cell = new[] { "foo 2", "bar 2", "https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=hello|world" } }, } }, jsonrequestbehavior.allowget); }
which gives:
Comments
Post a Comment