Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQgrid: Get Json data

Is there any method I can get the full JSON data from jqGrid when datatype is local along with the column name?

In this format: [{"firstname": "Chris"},{"firstname": "Dave"}]

like image 917
Alaa Osta Avatar asked Jun 18 '12 13:06

Alaa Osta


1 Answers

You can use the getRowData method to return an array containing all of the grid data. For example:

var fullData = jQuery("#myGrid").jqGrid('getRowData');

Here is the documentation for getRowData from the jqGrid wiki, which helps explain what is going on:

getRowData


Parameters: rowid or none

Returns: array

Description:

Returns an array with data of the requested id = rowid. The returned array is of type name:value, where the name is a name from colModel and the value from the associated column in that row. It returns an empty array if the rowid can not be found.

If the rowid is not set the method return all the data from the grid in array


Update

You might also be interested in the data parameter, which can be used to retrieve the data passed to the grid. From the jqGrid docs:

An array that stores the local data passed to the grid. You can directly point to this variable in case you want to load an array data. It can replace the addRowData method which is slow on relative big data

For example:

var data = $('#' + gridid).jqGrid('getGridParam', 'data');

Does that help?

like image 187
Justin Ethier Avatar answered Oct 28 '22 12:10

Justin Ethier