Can someone post a demo or a piece of code, to exemplify how to use jqpivot and loading data using ajax. Thank you.
JqPivot and data load by ajax
1.2k views Asked by David O. At
1
Can someone post a demo or a piece of code, to exemplify how to use jqpivot and loading data using ajax. Thank you.
I would recommend you to examine the source code of free jqGrid. Look at the part of the code. It looks like
You will get practically directly the answer on your question. You need specify the URL to the server which provides the input data in JSON form. No other data format is supported (
"xml"
,"jsonp"
and so on) directly, but you can useajaxOpt
parameter to overwrite the parameters of the Ajax call. It's important to understand additionally, that jqGrid uses$.jgrid.getAccessor
method to read the data from the server response. The default data format should be the following:where the value of "rows" should have the same format as the
data
parameter ofjqPivot
if you use if without Ajax. If you have for examplethen you can use 4-th parameter of jqPivot (
ajaxOpt
) asIf the response from the server is array of data:
or it have some non-standard form than you can use function form of
reader
. For exampleThe above code specify the reader at the function which use all the response data directly (without object with
rows
property). It specifiescontentType
andtype
parameter of the jQuery.ajax and the callback functionerror
.If all the options seems you too difficult you can load the data directy in your code with direct call of
jQuery.ajax
for example and the calljqPivot
after the data are loaded (inside ofsuccess
callback ordone
).