Can I export a charts from web page to PDF format? - html

There are the charts from the web page that made with canvas and I'd like to export to the PDF format file. Can I do like that ?
Thank you for suggestion.

You can with charting libraries like ZingChart. Simply right-click the chart to display the context menu. Select the Download PDF menu item to export the chart as a PDF. Try it on the below chart.
zingchart.THEME="classic";
var myConfig = {
"background-color":"#ecf2f6",
"graphset":[
{
"type":"bar",
"background-color":"#fff",
"border-color":"#dae5ec",
"border-width":"1px",
"height":"30%",
"width":"96%",
"x":"2%",
"y":"3%",
"title":{
"margin-top":"7px",
"margin-left":"9px",
"font-family":"Arial",
"text":"DEPARTMENT PERFORMANCE",
"background-color":"none",
"shadow":0,
"text-align":"left",
"font-size":"11px",
"font-weight":"bold",
"font-color":"#707d94"
},
"scale-y":{
"values":"0:300:100",
"max-ticks":4,
"max-items":4,
"line-color":"none",
"tick":{
"visible":false
},
"item":{
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"10px",
"padding-right":"5px"
},
"guide":{
"rules":[
{
"rule":"%i == 0",
"line-width":0
},
{
"rule":"%i > 0",
"line-style":"solid",
"line-width":"1px",
"line-color":"#d2dae2",
"alpha":0.4
}
]
}
},
"scale-x":{
"items-overlap":true,
"max-items":9999,
"values":["Apparel","Drug","Footwear","Gift Card","Home","Jewelry","Garden","Other"],
"offset-y":"1px",
"line-color":"#d2dae2",
"item":{
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"11px",
"padding-top":"2px"
},
"tick":{
"visible":false,
"line-color":"#d2dae2"
},
"guide":{
"visible":false
}
},
"plotarea":{
"margin":"45px 20px 38px 45px"
},
"plot":{
"bar-width":"33px",
"hover-state":{
"visible":false
},
"animation":{
"delay":500,
"effect":"ANIMATION_SLIDE_BOTTOM"
},
"tooltip":{
"font-color":"#fff",
"font-family":"Arial",
"font-size":"11px",
"border-radius":"6px",
"shadow":false,
"padding":"5px 10px",
"background-color":"#707e94"
}
},
"series":[
{
"values":[150,165,173,201,185,195,162,125],
"styles":[
{
"background-color":"#4dbac0"
},
{
"background-color":"#25a6f7"
},
{
"background-color":"#ad6bae"
},
{
"background-color":"#707d94"
},
{
"background-color":"#f3950d"
},
{
"background-color":"#e62163"
},
{
"background-color":"#4e74c0"
},
{
"background-color":"#9dc012"
}
]
}
]
},
{
"type":"hbar",
"background-color":"#fff",
"border-color":"#dae5ec",
"border-width":"1px",
"x":"2%",
"y":"35.2%",
"height":"63%",
"width":"30%",
"title":{
"margin-top":"7px",
"margin-left":"9px",
"text":"BRAND PERFORMANCE",
"background-color":"none",
"shadow":0,
"text-align":"left",
"font-family":"Arial",
"font-size":"11px",
"font-color":"#707d94"
},
"scale-y":{
"line-color":"none",
"tick":{
"visible":false
},
"item":{
"visible":false
},
"guide":{
"visible":false
}
},
"scale-x":{
"values":["Kenmore","Craftsman","DieHard","Land's End","Laclyn Smith","Joe Boxer"],
"line-color":"none",
"tick":{
"visible":false
},
"item":{
"width":200,
"text-align":"left",
"offset-x":206,
"offset-y":-12,
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"11px",
"padding-bottom":"8px"
},
"guide":{
"visible":false
}
},
"plot":{
"bars-overlap":"100%",
"bar-width":"12px",
"thousands-separator":",",
"tooltip":{
"font-color":"#ffffff",
"background-color":"#707e94",
"font-family":"Arial",
"font-size":"11px",
"border-radius":"6px",
"shadow":false,
"padding":"5px 10px"
},
"hover-state":{
"background-color":"#707e94"
},
"animation":{
"delay":500,
"effect":"ANIMATION_EXPAND_LEFT"
}
},
"plotarea":{
"margin":"50px 15px 10px 15px"
},
"series":[
{
"values":[103902,112352,121823,154092,182023,263523],
"z-index":2,
"styles":[
{
"background-color":"#4dbac0"
},
{
"background-color":"#4dbac0"
},
{
"background-color":"#4dbac0"
},
{
"background-color":"#4dbac0"
},
{
"background-color":"#4dbac0"
},
{
"background-color":"#4dbac0"
}
],
"tooltip-text":"$%node-value"
},
{
"max-trackers":0,
"values":[300000,300000,300000,300000,300000,300000],
"data-rvalues":[103902,112352,121823,154092,182023,263523],
"background-color":"#d9e4eb",
"z-index":1,
"value-box":{
"visible":true,
"offset-y":"-12px",
"offset-x":"-54px",
"text-align":"right",
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"11px",
"text":"$%data-rvalues",
"padding-bottom":"8px"
}
}
]
},
{
"type":"line",
"background-color":"#fff",
"border-color":"#dae5ec",
"border-width":"1px",
"width":"64%",
"height":"63%",
"x":"34%",
"y":"35.2%",
"title":{
"margin-top":"7px",
"margin-left":"12px",
"text":"TODAY'S SALES",
"background-color":"none",
"shadow":0,
"text-align":"left",
"font-family":"Arial",
"font-size":"11px",
"font-color":"#707d94"
},
"plot":{
"animation":{
"delay":500,
"effect":"ANIMATION_SLIDE_LEFT"
}
},
"plotarea":{
"margin":"50px 25px 70px 46px"
},
"scale-y":{
"values":"0:100:25",
"line-color":"none",
"guide":{
"line-style":"solid",
"line-color":"#d2dae2",
"line-width":"1px",
"alpha":0.5
},
"tick":{
"visible":false
},
"item":{
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"10px",
"padding-right":"5px"
}
},
"scale-x":{
"line-color":"#d2dae2",
"line-width":"2px",
"values":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
"tick":{
"line-color":"#d2dae2",
"line-width":"1px"
},
"guide":{
"visible":false
},
"item":{
"font-color":"#8391a5",
"font-family":"Arial",
"font-size":"10px",
"padding-top":"5px"
}
},
"legend":{
"layout":"x4",
"background-color":"none",
"shadow":0,
"margin":"auto auto 15 auto",
"border-width":0,
"item":{
"font-color":"#707d94",
"font-family":"Arial",
"padding":"0px",
"margin":"0px",
"font-size":"9px"
},
"marker":{
"show-line":"true",
"type":"match",
"font-family":"Arial",
"font-size":"10px",
"size":4,
"line-width":2,
"padding":"3px"
}
},
"crosshair-x":{
"lineWidth":1,
"line-color":"#707d94",
"plotLabel":{
"shadow":false,
"font-color":"#000",
"font-family":"Arial",
"font-size":"10px",
"padding":"5px 10px",
"border-radius":"5px",
"alpha":1
},
"scale-label":{
"font-color":"#ffffff",
"background-color":"#707d94",
"font-family":"Arial",
"font-size":"10px",
"padding":"5px 10px",
"border-radius":"5px"
}
},
"tooltip":{
"visible":false
},
"series":[
{
"values":[69,68,54,48,70,74,98,70,72,68,49,69],
"text":"Kenmore",
"line-color":"#4dbac0",
"line-width":"2px",
"shadow":0,
"marker":{
"background-color":"#fff",
"size":3,
"border-width":1,
"border-color":"#36a2a8",
"shadow":0
},
"palette":0
},
{
"values":[51,53,47,60,48,52,75,52,55,47,60,48],
"text":"Craftsman",
"line-width":"2px",
"line-color":"#25a6f7",
"shadow":0,
"marker":{
"background-color":"#fff",
"size":3,
"border-width":1,
"border-color":"#1993e0",
"shadow":0
},
"palette":1,
"visible":1
},
{
"values":[42,43,30,50,31,48,55,46,48,32,50,38],
"text":"DieHard",
"line-color":"#ad6bae",
"line-width":"2px",
"shadow":0,
"marker":{
"background-color":"#fff",
"size":3,
"border-width":1,
"border-color":"#975098",
"shadow":0
},
"palette":2,
"visible":1
},
{
"values":[25,15,26,21,24,26,33,25,15,25,22,24],
"text":"Land's End",
"line-color":"#f3950d",
"line-width":"2px",
"shadow":0,
"marker":{
"background-color":"#fff",
"size":3,
"border-width":1,
"border-color":"#d37e04",
"shadow":0
},
"palette":3
}
]
}
]
};
zingchart.render({
id : 'myChart',
data : myConfig,
height: 500,
width: '100%'
});
.zc-ref {
display: none;
}
<head>
<script src= "https://cdn.zingchart.com/zingchart.min.js"></script>
<script> zingchart.MODULESDIR = "https://cdn.zingchart.com/modules/";
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9","ee6b7db5b51705a13dc2339db3edaf6d"];</script></head>
<body>
<div id='myChart'><a class="zc-ref" href="https://www.zingchart.com/">Powered by ZingChart</a></div>
</body>
There's more information about chart export here: https://www.zingchart.com/docs/integrations/phantomjs-chart-export/
Disclaimer: I'm on the ZingChart team. Let me know if you have further questions.

Related

How to align 0 value in multiple y axis layered chart in Vega-lite?

In Vega-lite, I want to align y-axis values, so that zeroes are in the same place and negative values go below x-axis. Is it possible to do in Vega-lite? I can't hardcode the domain limits, as the data passed to this chart is dynamic, thus can be different every time.
My code:
{
"$schema":"https://vega.github.io/schema/vega-lite/v5.json",
"width":300,
"data":{
"values":[
{
"key":"Type A",
"sum1":"1000",
"sum2":"2000",
"ratio":"15"
},
{
"key":"Type B",
"sum1":"1500",
"sum2":"1500",
"ratio":"-5"
},
{
"key":"Type C",
"sum1":"2000",
"sum2":"1000",
"ratio":"7"
}
]
},
"layer":[
{
"mark":{
"type":"bar",
"size":15,
"xOffset":0
},
"encoding":{
"y":{
"field":"sum1",
"type":"quantitative",
"axis":{
"title":null,
"ticks":true,
"orient":"left"
}
},
"x":{
"field":"key",
"type":"nominal",
"axis":{
"title":null,
"labelAngle":-45,
"labelLimit":1000
}
},
"color":{
"datum":"Sum1"
}
}
},
{
"mark":{
"type":"bar",
"size":15,
"xOffset":15
},
"encoding":{
"y":{
"field":"sum2",
"type":"quantitative",
"axis":{
"domain":false,
"title":null,
"labels":false,
"ticks":false
}
},
"x":{
"field":"key",
"type":"nominal",
"axis":{
"title":null,
"labelAngle":-45,
"labelLimit":1000
}
},
"color":{
"datum":"Sum2"
}
}
},
{
"mark":{
"type":"line",
"interpolate":"monotone",
"clip":true
},
"encoding":{
"y":{
"type":"quantitative",
"field":"ratio",
"axis":{
"title":null,
"ticks":true,
"orient":"right"
}
},
"x":{
"field":"key",
"type":"nominal",
"axis":{
"title":null,
"labelAngle":-45,
"labelLimit":1000
}
},
"color":{
"datum":"Ratio"
}
}
}
],
"resolve":{
"scale":{
"y":"independent"
}
},
"config":{
"legend":{
"orient":"bottom",
"columns":3,
"labelLimit":500,
"layout":{
"bottom":{
"anchor":"middle"
}
}
}
}
}
Open the Chart in the Vega Editor

Define Colors on repeated layers in Vega-Lite

I have this definition of a Vega-Lite chart
{
"$schema":"https://vega.github.io/schema/vega-lite/v4.json",
"data":{
"values":[
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444444",
"lowval":45000,
"highval":45500,
"resultdecimal":45466
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444445",
"lowval":45000,
"highval":45500,
"resultdecimal":45433
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444446",
"lowval":45000,
"highval":45500,
"resultdecimal":45400
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444447",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444448",
"lowval":45000,
"highval":45500,
"resultdecimal":45403
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444449",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
}
]
},
"repeat":{
"layer":[
"lowval",
"highval",
"resultdecimal"
]
},
"spec":{
"mark":{
"type":"line",
"strokeWidth":3,
"point":{
"size":45,
"filled":true
}
},
"encoding":{
"x":{
"field":"serialnumber",
"type":"ordinal",
"axis":{
"labelAngle":-70,
"title":"Selected Tests",
"titleFontSize":10
}
},
"y":{
"field":{
"repeat":"layer"
},
"type":"quantitative",
"axis":{
"title":"Teststeps in selected Tests",
"titleFontSize":10
},
"scale":{
"domain":[
45000,
45500
]
}
},
"tooltip":[
{
"field":"serialnumber",
"type":"ordinal"
},
{
"field":"resultdecimal",
"type":"quantitative"
}
],
"color":{
"datum":{
"repeat":"layer"
},
"type":"nominal"
}
}
},
"config":{
"font":"Roboto",
"axisX":{
"labelFontSize":9
},
"axisY":{
"labelFontSize":9
}
}
}
The outcome is like this:
What i want to achieve is to define the colors of the lines based on the field names
if( highval)
color = red
if( lowval)
color = red
if (resultdecimal)
color = blue
so that the min-max is in red, the result is in blue.
If there is another way of displaying three different chart-lines and defining the values there properly, any ideas are welcome!
i think i found the answer:
here the vega-lite definition for conditional color
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444444",
"lowval":45000,
"highval":45500,
"resultdecimal":45466
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444445",
"lowval":45000,
"highval":45500,
"resultdecimal":45433
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444446",
"lowval":45000,
"highval":45500,
"resultdecimal":45400
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444447",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444448",
"lowval":45000,
"highval":45500,
"resultdecimal":45403
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444449",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
}
]
},
"repeat": {
"layer": ["lowval", "highval","resultdecimal"]
},
"spec": {
"mark":{
"type":"line",
"strokeWidth":3,
"point":{
"size":45,
"filled":true
}
},
"encoding": {
"x": {
"field": "serialnumber",
"type": "ordinal",
"axis":{
"labelAngle":-70,
"title":"Selected Tests",
"titleFontSize":10
}
},
"y": {
"field": {"repeat": "layer"},
"type": "quantitative",
"axis": {
"title": "Teststeps in selected Tests",
"titleFontSize": 10},
"scale":{
"domain":[45000,45500]
}
},
"tooltip":[
{
"field":"serialnumber",
"type":"ordinal"
},
{
"field":"resultdecimal",
"type":"quantitative"
}
],
"color": {
"datum": {"repeat": "layer"},
"type": "nominal",
"scale": {
"range": ["#e7ba52", "#c7c7c7", "#e7ba52"]
},
"legend": {"title": "Weather type"}
}
}
},
"config": {
"font": "Roboto",
"axisX": {
"labelFontSize": 9
},
"axisY": {
"labelFontSize": 9
}
}
}

Rescale Chart in Vega-Lite

We have this dataset which we want to visualize with Vega/Vega-Lite
{
"$schema":"https://vega.github.io/schema/vega-lite/v4.13.json",
"description":"Testing",
"width":"container",
"height":350,
"autosize":{
"type":"fit",
"contains":"padding"
},
"layer":[
{
"data":{
"values":[
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444444",
"lowval":45000,
"highval":45500,
"resultdecimal":45466
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444445",
"lowval":45000,
"highval":45500,
"resultdecimal":45433
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444446",
"lowval":45000,
"highval":45500,
"resultdecimal":45400
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444447",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444448",
"lowval":45000,
"highval":45500,
"resultdecimal":45403
},
{
"stepid":"4444",
"stepname":"Name1",
"serialnumber":"SN3444449",
"lowval":45000,
"highval":45500,
"resultdecimal":45422
}
]
},
"layer":[
{
"mark":{
"type":"line",
"strokeWidth":3,
"point":{
"size":45,
"filled":true
},
"interpolate":"monotone"
},
"encoding":{
"x":{
"field":"serialnumber",
"type":"ordinal",
"axis":{
"labelAngle":-70,
"title":"Selected Tests",
"titleFontSize":10
}
},
"y":{
"field":"resultdecimal",
"type":"quantitative",
"axis":{
"title":"Teststeps in selected Tests",
"titleFontSize":10
}
},
"tooltip":[
{
"field":"serialnumber",
"type":"ordinal"
},
{
"field":"resultdecimal",
"type":"quantitative"
}
]
}
},
{
"mark":"rule",
"encoding":{
"y":{
"field":"highval"
},
"stroke":{
"value":"#FF0000"
}
}
},
{
"mark":"rule",
"encoding":{
"y":{
"field":"lowval"
},
"stroke":{
"value":"#FF0000"
}
}
}
]
}
]
}
Everything works fine but the scaling on the y-axis is not too optimal
Is it possible to rescale y-axis so it is more scaled-into-view based on lowval and highval e.g. like this one?
Furthermore is it possible to write the "lowval" and "highval" values on top of the lines?
You can control the y-axis domain using the scale.domain property:
"y": {
"field": "resultdecimal",
"type": "quantitative",
"axis": {
"title": "Teststeps in selected Tests",
"titleFontSize": 10
},
"scale": {
"domain": [45000, 45500]
}
},
Adding that to your chart, results in this (view in editor):

ElasticSearch Nest Msearch fn does not bring all results

My aim is to send 3 separate queries in one ES request using multiple search
I am using NEST client to send query to Elastic search using function below
IElasticClient _elasticClient.LowLevel.Msearch<string>(query).Body;
Passing as a raw query using curl command works absolutely fine, but NEST MSearch only returns "event_results" and "venue_results" but not "location_results"
curl -XPOST localhost:9200/_msearch -d '
{"index" : "search_results"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "name": "manchester" } } ] } }, "aggs": { "event_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
{"index" : "search_results2"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "venueName": "Manchester" } } ] } }, "aggs": { "venue_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
{"index" : "search_results3"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "venueTown": "manchester" } } ] } }, "aggs": { "location_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
'
Is any of you know where the issue could be?
Whenever possible, you don't want to use the "LowLevel" stuff. Instead, use what is available to you on the IElasticClient. Here is an example of how to use IElasticClient.MultiSearch to run 3 searches using the fluent syntax (which is the preferred way to do this).
var mSearchResponse = ElasticClient.MultiSearch(msearch => msearch
.Search<RedemptionES>(
s1 => s1.Query(
q=>q.Term(
t=> t.OnField(f=> f.Id).Value("123")
)
)
)
.Search<RedemptionES>(
s2 => s2.Query(
q => q.Term(
t => t.OnField(f => f.Id).Value("456")
)
)
)
.Search<RedemptionES>(
s3 => s3.Query(
q => q.Term(
t => t.OnField(f => f.Id).Value("789")
)
)
)
);
Issue lies on indention. Try this:
public static string qu = #"{""index"" : ""search_results""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""name"": ""manchester"" } } ] } }, ""aggs"": { ""event_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
{""index"" : ""search_results2""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""venueName"": ""Manchester"" } } ] } }, ""aggs"": { ""venue_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
{""index"" : ""search_results3""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""venueTown"": ""manchester"" } } ] } }, ""aggs"": { ""location_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
";
var result = _elasticClient.LowLevel.Msearch<string>(qu).Body; // Query ES for results.

jqgrid - pagination

I have the following JSON structure
JSON
{
"page":"1",
"total":"3",
"records":"15",
"mypage":{
"outerwrapper":{
"innerwrapper":{
"rows":[
{
"id":"1",
"read": true,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
},
{
"name":"link3"
}
]
}
]
},
{
"id":"2",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"3",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"4",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"5",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"6",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"7",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"8",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"9",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"10",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"11",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"12",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"13",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"14",
"read": false,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
},
{
"id":"15",
"read": true,
"cells": [
{
"label":"linkimg",
"links": [
{
"name":"link1"
},
{
"name":"link2"
}
]
}
]
}
]
}
}
}
}
Please note: that page, total and records for pagination are defined before mypage. This works. I get Page 1 of 3, 2 of 3 and 3 of 3. BUT
If I place page, total and records for pagination after outerwrapper, then it doesn't work. I get Page 0 of 3
{
"mypage":{
"outerwrapper":{
"page":"1",
"total":"3",
"records":"15",
....
....
}
}
}
If you want change the place of page, total and records inside of your JSON input data you have to inform jqGrid about the new place. You can do this using jsonReader. For example you can add the following jsonReader to the list of parameters of jqGrid
jsonReader: {
page: 'mypage.outerwrapper.page',
total: 'mypage.outerwrapper.total',
records: 'mypage.outerwrapper.records'
}