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.3k 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 useajaxOptparameter to overwrite the parameters of the Ajax call. It's important to understand additionally, that jqGrid uses$.jgrid.getAccessormethod 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
dataparameter ofjqPivotif 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
rowsproperty). It specifiescontentTypeandtypeparameter 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.ajaxfor example and the calljqPivotafter the data are loaded (inside ofsuccesscallback ordone).