Mark B
Mark B

Reputation: 4928

jqGrid not showing "no records to view" message when there are no records to view

I'm having trouble with jqGrid not showing the "No records to view" message when there are no records to view. I've used jqGrid pretty extensively in my application, with variable row count selection, pagination, and filtering. When the tables are initially loaded, they correctly show the number of pages, and the "View 1-10 of 50" type rowcount message. If filters are then applied to the table, the data in the table is updated correctly (using a JSON data source generated by PHP), and the page and row count messages are updated correctly.

The only problem comes when filters are applied which return no rows at all - when this happens, the page count and row count messages remain set to their previous values.

I've checked the JSON I'm returning for an empty data set, and it matches the JSON from the jqGrid demo site when there is no data:

{"page":0,"total":0,"records":"0"}

I've posted a sample at http://www.analyticsseo.com/test. Any idea what I'm doing wrong?

Upvotes: 0

Views: 2621

Answers (1)

Oleg
Oleg

Reputation: 221997

I don't recommend you now so old version of jqGrid like 3.8. You main problem with server response

{"page":0,"total":0,"records":"0"}

can be fixed if the server would produce

{"page":0,"total":0,"records":"0","rows":[]}

instead. The bug like many other bugs are fixed in jqGrid now. There are many new features and performance improvements.

By the way your server part use wrong Content-Type header in the response with the JSON data. The correct Content-Type is application/json, but your server uses currently text/html; charset=utf-8 instead. You can use in Drupal 6, common.inc the statement drupal_set_header('Content-Type: application/json'); to fix the problem. After such change you will be able to use more recent version of jQuery.

In the answer you find references to the link which describes how you can upgrade jQuery to new version.

Upvotes: 1

Related Questions