JQgrid: Get Json data
Asked Answered
S

1

6

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"}]

Sholem answered 18/6, 2012 at 13:35 Comment(0)
C
14

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?

Charente answered 18/6, 2012 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.