The code which you posted have many problems on both client and the server side. I'll mention only some of the problems.
Your main problem is in the server code which you use. You use currently in the server code
...
new { n.QUICKFIX_ID,
cell = new string[] {
n.QUICKFIX_ID.ToString(),
n.NAME_TXT.ToString(),
n.DESCRIPTION_TXT.ToString(),
n.INSTRUCTIONS_TXT.ToString(),
n.TYPE_TXT.ToString(),
n.FIXLINK_TXT.ToString()}
}
...
which seems should be changed to
...
new {
id = n.QUICKFIX_ID,
cell = new [] {
n.NAME_TXT.ToString(),
n.DESCRIPTION_TXT.ToString()
}
}
...
You should additionally to consider to remove .AsEnumerable()
or to move it after select
are applied.
First of all index
property have only some meaning in server side sorting. The server code which you posted don't use sidx
and sord
parameters. So you should remove all index
properties from the colModel
. If no index
property specified jqGrid uses the same value for index
as the value name
property. It's what one need in 99% of scenarios. So I recommend you to specify no index
property. Because you use array format of items (cell = new string[] {...}
the choice of name
property is free. You can use name: 'NAME_TXT'
in the same way like name: 'NAME'
. If the names of columns in the database are NAME_TXT
and DESCRIPTION_TXT
I would personally prefer to use the same values for name
.
Default value of align
property is already 'left'
. So it's better to remove unneeded align: 'left'
property from colModel
. The value of '500px'
for height
option is wrong. Correct values are the string "auto"
or the string "100%"
or any integer value like height: 500
. I personally like to use height: "auto"
.
jqGrid don't have contentType
option. If you need to specify contentType
of HTTP request you should use {ajaxGridOptions: { contentType: "application/json; charset=utf-8" }
instead. The option repeatitems
don't exist and it should be removed. On the other side I would recommend you to add two other options in jqGrid: gridview: true
and autoencode: true
.
One more very important option is rowNum
. It's default value is 20
. The value will be sent to the server as the value of rows
parameter (see parameters of LinqGridData
). The server should return only rows
items of data sorted by sidx
. If the server returns more as rows
items (more as 20 items) jqGrid will still display only the first rows
items (only the first 20 items). Typically grid have the pager bar at the bottom or at the top of grid. So the user can go to another page. You don't use currently neither page
nor toppager
option. As the result the grid will contains up to 20 rows, and the user will have no possibility to use paging to see the rest data. I recommend you to use pager
or toppager: true
option or at least you should include rowNum: 10000
option to display up to 10000 rows returned from the server.
If you don't implemented server side paging, sorting and filtering of data you can return all data to jqGrid, but use loadonce: true
option of jqGrid. In the case all data will be saved locally, datatype
will be changed to "local"
after the first loading from the server and the user will able to sort data locally or to use paging without require that you write any additional code. It's very practical option if the data which you need display (tbl_Quickfix_Toolbar
) are not too large.